Using Sjcl i try to write a little service sending and receiving encrypted data from my javascript application.
Sadly, the sjcl documentation is lacking information on how to process their AES
encrypted data.
Their encrypt method returns an object containing serveral attributes of which i can only guess what is what.
{"iv":"i0t5BttfXwtY6hxuFSZxJg==",
"v":1,
"iter":1000,
"ks":128,
"ts":64,
"mode":"ccm",
"cipher":"aes",
"salt":"MZ8hpbz+5hU=",
"ct":"n5mR5jwawYwsaUV0xbcYXrcCXPWjR5qMG23qU5Spguz4jpjG5QdFMWSf"}
I can identify iter
, ks
, ts
, mode
, cipher
and salt
. My guess is that ct
is the cipher text, representing the encrypted data. But what is v
and iv
?
I tried decrypting my cipher text giving ct
as a parameter and even tried giving the whole result as a parameter but it always just produces errors:
var result = sjcl.json.encrypt(
'pw123',
'{text: "this should be decrypted"}',
parameters,
rp
);
var originalText = sjcl.json.decrypt(
'pw123',
result.ct,
parameters,
rp);
// Results in:
// Uncaught TypeError: Cannot read property 'replace' of undefined
How do i decrypt my ct
using their decrypt method?
Anyone any experience with this and can give a brief example?