<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
<script>
var toEncMes = "This is a secret message.";
var secPas = "myPassword";
var encrypted = CryptoJS.AES.encrypt(toEncMes, secPas);
alert (encrypted);
var decrypted = CryptoJS.AES.decrypt(encrypted, secPas);
alert (decrypted);
</script>
I probably just don't understand the concept but I have no idea.
The end result from my code is still just a jumbled mess when I display decrypted result.
I found this here: https://code.google.com/p/crypto-js/
The original entry looks like this:
The Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated.
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"> </script>
<script>
var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");
var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase");
</script>
CryptoJS supports AES-128, AES-192, and AES-256. It will pick the variant by the size of the key you pass in. If you use a passphrase, then it will generate a 256-bit key.
"myPassword"
is too small a secret for any variant of AES, so it's probably creating a secret from that. Maybe it does that forencrypt
but not fordecrypt
. Can you try using a 256 bit key instead of a passphrase? – Mike Samuel Apr 25 at 21:39