I put together a simple test using the example from the Crypto-JS source site at Google code:
In page header:
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
In a Javascript function:
var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");
var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase");
alert('encrypted: '+encrypted+' decrypted: '+decrypted);
but the output is:
encrypted: U2FsdGVkX19hsNqFBS5xcUoVBCu/hPHepEwZchqnUVU=
decrypted: 4d657373616765
What am I missing?
decrypted.toString(CryptoJS.enc.Utf8) // "Message"
See https://code.google.com/p/crypto-js/#The_Hasher_Output
The hash you get back isn't a string yet. It's a WordArray object. When you use a WordArray object in a string context, it's automatically converted to a hex string.
You can convert a WordArray object to other formats by explicitly calling the toString method and passing an encoder.