Skip to content
Advertisement

CryptoJS decrypted value differ from the original value

I am trying to encrypt some strings and decrypt it with the use of CryptoJS (AES-256).

My javascript code:

JavaScript

My setup:
fefe3124bdc21e8a1c1b3fdfb84c79950b394b8f86fd49dddb616037b1bc2474 (key)

a (Input)

Qw== (Encrypted string)

d5 (decrypted value)

May I know which part of my code logic is wrong ?

Advertisement

Answer

Alright, I have figured out why the value would be different. Just need to remove the padding option, the decrypted value will be same as the original.

var encrypted = CryptoJS.AES.encrypt(xx, key, {iv: iv});

var decrypted = CryptoJS.AES.decrypt(encryptedString, key,{iv:iv});

I am just adding this answer, incase someone had the same issue as me.

Cheers!

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement