bitwiseshiftleft / sjcl

Stanford Javascript Crypto Library
http://bitwiseshiftleft.github.com/sjcl/
Other
7.19k stars 988 forks source link

Encrypting and decrypting objects directly? #351

Open laurent22 opened 6 years ago

laurent22 commented 6 years ago

The functions sjcl.json.encrypt and sjcl.json.decrypt deal with serialised JSON, however for my use case I would like to store the encrypted data and metadata (iter, ks, etc.) separately, which is much easier if dealing with Javascript objects.

Also I see that the lib is using a custom encode/decode which I guess is slower than a built-in JSON.stringify/JSON.parse?

There are _encrypt and _decrypt functions in convenience.js, which deal with objects but unfortunately they are not in the build.

Is there any other way to achieve the above? Basically encrypting/decrypting objects directly?

cnasikas commented 6 years ago

By reading the code I couldn't find any way to achieve it. I think, for the moment, you have to use JSON.parse to do operation over the results.