I am encrypting some data using CryptoJS and comparing it to an online tool and I am not getting the same result. In fact the result from CryptoJS in not decryptable with the tool.
I am trying to encrypt in AES-256-CBC with the following parameters:
text = '111222333'
iv = 'I8zyA4lVhMCaJ5Kg'
key = '6fa979f20126cb08aa645a8f495f6d85'
Here's my code:
let text = '111222333';
aesEncrypt(data) {
let key = '6fa979f20126cb08aa645a8f495f6d85'; //length 32
let iv = 'I8zyA4lVhMCaJ5Kg'; //length 16
let cipher = CryptoJS.AES.encrypt(data, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
return cipher.toString();
}
aesEncrypt(text);
The resulting encrypted string is U2FsdGVkX1+f3UywYmIdtb50bzdxASRCSqB00OijOb0=
while the one obtained with the online tool is B6AeMHPHkEe7/KHsZ6TW/Q==
. Why are they different, I seem to be using the same parameters?
My plan in using CryptoJS is to encrypt some data client side and then be able to decrypt it server side, if needed. But the differences in both encrypted values is stopping me to do so.