jonS90
jonS90

Reputation: 1379

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"?

Upvotes: 0

Views: 934

Answers (1)

Zergatul
Zergatul

Reputation: 2010

decrypted.toString(CryptoJS.enc.Utf8)

Upvotes: 4

Related Questions