2

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

HolySamosa
  • 9,011
  • 14
  • 69
  • 102

2 Answers2

3

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

Hot Licks
  • 47,103
  • 17
  • 93
  • 151
2

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

Community
  • 1
  • 1
Paul Jowett
  • 6,513
  • 2
  • 24
  • 19