简体   繁体   中英

CryptoJS AES encryption is not symmetric?

I can't seem to get CryptoJS.AES to properly decrypt what it encrypted. Please look at this javascript code:

var plaintext = "Message";
var encrypted = CryptoJS.AES.encrypt(plaintext, "Secret Passphrase");
var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase");
console.log(plaintext);
console.log(encrypted.toString());
console.log(decrypted.toString());

The resulting output is

Message
U2FsdGVkX18Y2Cs77gkggFx8fkEajT1uztVYRkSkt/E
4d657373616765

Why aren't I getting back the original "Message" ?

decrypted.toString(CryptoJS.enc.Utf8)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM