title: AES Encrypt in CryptoJS and decrypt in Coldfusion
body: <p>We've got a Silent Login service written in Coldfusion9 that accepts encrypted strings from external systems and then decrypts based on an agreed Algorithm/Encoding setup. This has worked without issue for years now from systems running ASP/JAVA/PHP, but we now have a client who has no choice but to use CryptoJS to perform the encryption and for the life of me I cannot work out why this won't decrypt in Coldfusion.</p>
  
  <p>My knowledge of encryption isn't brilliant but the thing I am noticing is the CryptoJS encrypted ciphertext for the exact same string/key differs every time i perform the encryption whereas in Coldfusion/Java i can always expect the exact same encrypted string. I'm not sure if this is encoding related or not but i've never run into this issue accepting encrypted strings from any other system before, so I am hoping it's the way I am encrypting in CryptoJS that is incorrect.</p>
  
  <pre><code>&lt;cfoutput&gt;
  
  &lt;!--- Set String and Key ---&gt;
  &lt;cfset theKey = toBase64("1234567812345678")&gt;
  &lt;cfset string = "max.brenner@google.com.au"&gt;
  
  &lt;!--- CryptoJS AES Libraries ---&gt;
  &lt;script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"&gt;&lt;/script&gt;
  &lt;script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  
  // Encrypt String using CryptoJS AES
  var encrypted = CryptoJS.AES.encrypt("#string#", "#theKey#");
  console.log(encrypted.toString());
  
  // Decrypt String using CryptoJS AES 
  var decrypted = CryptoJS.AES.decrypt(encrypted, "#theKey#");
  console.log(decrypted.toString(CryptoJS.enc.Utf8));
  
  &lt;/script&gt;
  
  &lt;!--- Coldfusion Decrypt String / FAILS ---&gt;
  Decrypted: #decrypt(encryptedEmail, "#theKey#", "AES", "BASE64")#
  
  &lt;/cfoutput&gt;
  </code></pre>