CF9 Encrypt with AES 256-bit, example anyone?
Hi there. I'm looking for a working example of the Encrypt method using the AES 256 bit key. I think that I have the Unlimited Strength Jurisdiction Policy Files enabled. And I'm still getting the CFError,
The key specified is not a valid key for this encryption: Illegal key size.
Now i hit the wall, can't get it. What wrong am i doing? How can I verify that the policy files are installed and accessible to my cf file? Any help is greatly appreciated.
<cfset thePlainText = "Is this working for me?" />
Generate Secret Key (128): <cfset AES128 = "#generatesecretkey('AES',128)#" /> <cfdump var="#AES128#"><BR>
Generate Secret Key (192): <cfset AES192 = "#generatesecretkey('AES',192)#" /> <cfdump var="#AES192#"><BR>
Generate Secret Key (256): <cfset AES256 = "#generatesecretkey('AES',256)#" /> <cfdump var="#AES256#"><BR><BR>
<cfset theKey = AES256 />
<cfset theAlgorithm = "AES/CBC/PKCS5Padding" />
<cfset theEncoding = "base64" />
<cfset theIV = BinaryDecode("6d795465737449566f7253616c7431323538704c6173745f", "hex") />
<cfset encryptedString = encrypt(thePlainText, theKey, theAlgorithm, theEncoding, theIV) />
<!--- Display results --->
<cfset keyLengthInBits = arrayLen(BinaryDecode(theKey, "base64")) * 8 />
<cfset ivLengthInBits = arrayLen(theIV) * 8 />
<cfdump var="#variables#" label="AES/CBC/PKCS5Padding Results" />
<cfabort>
