Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Is the value in the Coldfusion ThisKey:</p> <pre><code>&lt;cfset ThisKey = "a-24byte-key-string-here"&gt; </code></pre> <p>The exact same string that is returned from the java generateKey() function? I believe they need to be to be the same string for the generated encrypted text to be the same.</p> <p>To use a fixed key like that in CF, you may need to follow this from the <a href="http://kb2.adobe.com/cps/546/e546373d.html" rel="nofollow noreferrer">CF technote</a> on strong encryption:</p> <blockquote> <blockquote> <p>You may want to generate your own key for two reasons:</p> </blockquote> <ol> <li>You want to match the details of other encryption software.</li> <li>You want to increase the resistance to cracking of your encrypted data by pattern-oriented cryptanalysis techniques.</li> </ol> <p>For example, to create a 32-byte key to use with the AES algorithm with the hex value:</p> <p>8738fed68e7677d374e0946c8f7bd3bb4f50f23717f9f3667b2419483959039c</p> <p>you would use the ColdFusion functions BinaryDecode and ToBase64 to create the key:</p> </blockquote> <pre><code>&lt;cfset myKey = ToBase64(BinaryDecode("8738fed68e7677d374e0946c8f7bd3bb4f50f23717f9f3667b2419483959039c","Hex")&gt; &lt;cfset encrypted =Encrypt(myString, myKey, "AES")&gt; </code></pre> <p>EDIT: Just realized that the key (as you mentioned in your comment) is base64, so if the "generateKey" method in Java looks like:</p> <pre><code>private static Key generateKey() throws Exception { final byte[] decodedKey = new BASE64Decoder().decodeBuffer(KEY_VALUE); final Key key = new SecretKeySpec(decodedKey, _AES); return key; } </code></pre> <p>You should be golden.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload