CryptoJS AES加密不对称?

时间:2013-11-12 15:44:31

标签: javascript encryption cryptojs

我似乎无法让CryptoJS.AES正确解密它加密的内容。请看这个javascript代码:

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());

结果输出

Message
U2FsdGVkX18Y2Cs77gkggFx8fkEajT1uztVYRkSkt/E
4d657373616765

为什么我没有找回原来的"Message"

1 个答案:

答案 0 :(得分:3)

decrypted.toString(CryptoJS.enc.Utf8)