Open GoogleCodeExporter opened 9 years ago
> var bdata = data.toString('binary');
> var bkey = key.toString('binary');
> // ...
enc = CryptoJS.AES.encrypt(bdata,bkey);
You're passing both the data and the key as strings. CryptoJS will convert the
data string to bytes using UTF-8, and the key string is treated as a passphrase
from which to derive an actual key bytes. If you want CryptoJS to know that
this is raw binary data, then you need to convert it to a
CryptoJS.lib.WordArray object. Probably the simplest way to do that is:
CryptoJS.AES.encrypt(
CryptoJS.enc.Latin1.parse(bdata),
CryptoJS.enc.Latin1.parse(bkey)
)
Note that when you pass a literal key, then you also need to pass a literal IV.
Original comment by Jeff.Mott.OR
on 10 Apr 2014 at 9:30
Ok, right!
Another little question, I use the cryto.createCipher() of node.js, this method
admites 2 arguments (algorithm and password).
I use a PBKDF2 key generated with the password and a salt. But with the same
key generated using as password, CryptoJs and node crypto lib are not
compatible.
I think this is because each library generate the key/iv with different
algorithms.
If I want to use my owns generated key/iv, what sizes would be the expected?
BTW: If I use WordArray as phrasepassword this doesn't works.
Sorry my poor english :D
Original comment by Tios...@gmail.com
on 11 Apr 2014 at 9:39
Original issue reported on code.google.com by
Tios...@gmail.com
on 10 Apr 2014 at 8:23