Can I encrypt my JSON data?

87,732

Solution 1

If all you want is to prevent them from copying and pasting into something else, you could store it in BSON instead of JSON. http://bsonspec.org/#/specification

Now that only OBFUSCATES it, and will not prevent a knowledgeable person from using it if they want to.

You could also encrypt it, but you still have a similar issue as you would be storing the decrypt key inside the javascript that loads the encrypted Json.

Anyone that really wants your data is going to be able to get it. Most browser have javascript debuggers that will let you extract, or view the data at runtime.

So it mostly comes down to how much effort you want to put into making your data difficult to get at. A significantly motivated person with get at your data no matter what you do.

Solution 2

If you're only able to use JavaScript (no script-engine, like php), this library may be useful: http://code.google.com/p/crypto-js/

Solution 3

How about this: https://github.com/HazAT/jCryption ? It uses RSA for the key exchange and AES for the encryption.

Solution 4

I'm not sure which languages are supported by your platform but look at Silencio library which you can use to remove or hash nodes from JSON file. You can decide which nodes should be transformed (you may want to obfuscate only some such as password) and what change should be applied (clear the content, hash or custom)

Share:
87,732
Cris
Author by

Cris

Updated on October 10, 2020

Comments

  • Cris
    Cris over 3 years

    I'm developing a JQuery web app that will be executed locally from a DVD. The app will read all the contents of a JSON file.

    Is there a good way to encrypt or obfuscate the JSON content so that only the app can read it?

  • NiCk Newman
    NiCk Newman almost 9 years
    Hmm nice, but is jquery required to use it?
  • aLx13
    aLx13 almost 9 years
    @NiCkNewman here are other js crypto libraries: gist.github.com/jo/8619441 and benchmarks: dominictarr.github.io/crypto-bench
  • scienticious
    scienticious over 5 years
    How to use BSON in Java ? any sample will be helpful
  • Austin Harris
    Austin Harris over 5 years
    Check out protocol buffers. It's contract based, and does code generation. You might like it better.