This tutorial is amazing, it runs through CryptoJS, but unfortunately doesn’t make clear the most important point. This code demonstrates AES encryption and decryption:
var key = CryptoJS.lib.WordArray.random(16); var iv = CryptoJS.lib.WordArray.random(16); var encrypted = CryptoJS.AES.encrypt("Message", key.toString(), { iv: iv.toString() }); var decrypted = CryptoJS.AES.decrypt(encrypted.toString(), key.toString(), { iv: iv.toString() });
But if you can’t get the decrypted content at the end, you have to do this:
decrypted.toString(CryptoJS.enc.Utf8)
I’m sure this will save a lot of heartache.