I am getting an error when my data to decrypt is over 63973 string length. here is the code involved:
I set the static key and other values in a separate include file, cfencode obfuscated, located below the web root:
<cfset request.encryptKey = "xxxxxxxxxxxxxxxxxxxxxx=="> <!---// Key in base 64 //--->
<cfset request.encryptAlgorithm = "AES/CBC/PKCS5Padding" />
<cfset request.encryptEncoding = "Base64" />
<cfset request.encryptIV = BinaryDecode("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx9b0", "hex") />
The Algorithm, encoding and salt were selected to make the encrypt/decrypt compatible with other language encrypt/decrypt, like .Net, for future expansion/compatibility.
My encrypt/decrypt looks like this:
<cfset resultEncrypt = #Encrypt(unencrypted_text, request.encryptKey, request.encryptAlgorithm, request.encryptEncoding, request.encryptIV)#>
<cfset resultDecrypt = #Decrypt(encrypted_text, request.encryptKey, request.encryptAlgorithm, request.encryptEncoding, request.encryptIV)#>
The decrypt function is failing when the size (measured by Len(encrypted string)) of the encrypted string is over 63973, which typically seems to be 64000.
The error is: “An error occurred while trying to encrypt or decrypt your input string: The input and output encodings are not same..”
It does not fail other times, as a matter of fact it works like a charm.
Any ideas what I am doing wrong?
Strings can be any length, limited by the amount of available memory on the ColdFusion server. However, the default size limit for long text retrieval (CLOB) is 64K. The ColdFusion Administrator lets you increase the limit for database string transfers, but doing so can reduce server performance. To change the limit, select the Enable retrieval of long text option on the Advanced Settings page for the data source. see the documentation