jeremy303
jeremy303

Reputation: 9241

Simple Java encryption w/ JSON-friendly encoding?

I'm looking for a simple Java encryption solution that will allow me to specify the encoding such that the encrypted data can be embedded in a JSON document.

Why? My web service returns a descriptive JSON message when errors occur. In the event of an internal server error, I'd like to include a field that contains diagnostic information, however I want to encrypt this data to avoid potential security issues.

I'm going for something similar to YouTube's Internal Server Error, plus JSON and minus monkeys.:

YouTube 500 error

Upvotes: 2

Views: 9937

Answers (2)

Paul Jowett
Paul Jowett

Reputation: 6581

As Hot Licks said, encrypt using your choice method to achieve the level of SECURITY you want vs performance/simplicity. Then use Base64 encoding on that data to make it easy to transport in your JSON. There are several Base64 libraries around. Have a look at these stack overflow answers for good Java encryption options:

Java simple encryption

How to encrypt String in Java

Upvotes: 2

Hot Licks
Hot Licks

Reputation: 47729

Encrypt the data and return it as a base64 character string.

Upvotes: 3

Related Questions