Bill Rawlinson said the following on 2/14/2006 10:20 PM: > sort of - somehow my encrypted string is losing its trailing space. > However, buskirj encrypted comes out with a trailing 0 and a space > but if you decrypt either the encrypted buskirk without the trailing > space OR the encrypted buskirj they both return buskirj > > it is the only string I am having this problem with. I can't find a > single reason for losing the trailing space in the encrypted buskirk > but it is causing a user with that last name untold grief. > > Bill Yeah, you're losing the space somewhere. I wouldn't run a Trim on an encrypted value since CF's trim() actually calls java.lang.String.trim() under the hood.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#trim() If you read the link above, not only does it trim all spaces before and after the string -- it trims all ACII control characters as well. It is certainly possible that some characters are getting automatically trimmed when persisted in your Oracle DB. Secondly, I tried your first example (the one without the functions) and with repeated refreshing (although rarely) sometimes it throws: "Given final block not properly padded." I looked this up and it appears that the stock CFMX_COMPAT alog used in encrypt uses blocks for encryption -- triming any spaces/control characters can cause this error (and I assume your problem). If you are on CFMX 7, I suggest you switch to something like blowfish or AES (or at worst triple DES). Here's some example code: <cfset keys = "" /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset keys = listAppend(keys, generateSecretKey("AES")) /> <cfset alog = "AES"> <cfset testStrings = "buskirk,buskirj,rawlinson,smith,heinricher,farrell,johnson,packard,wacom,shuttle,netgear,maxtor,logitech,grey,glide"> <cffunction name="testEncrypt" output="false" returntype="string"> <cfargument name="key" type="string" required="true"> <cfargument name="value" type="string" required="true"> <cfset var endval = encrypt(value,key,alog) /> <cfreturn endval /> </cffunction> <cffunction name="testDecrypt" output="false" returntype="string"> <cfargument name="key" type="string" required="true"> <cfargument name="value" type="string" required="true"> <cfset var endval = decrypt(value,key,alog) /> <cfreturn endval /> </cffunction> <ol> <cfloop list="#keys#" index="key"> <cfloop list="#testStrings#" index="ts"> <cfset a = testEncrypt(key,ts) /> <cfset b = testDecrypt(key,a) /> <li><cfoutput>Does 1=3? #YesNoFormat(b EQ ts)#</cfoutput></li> </cfloop> </cfloop> </ol> -- Peter J. Farrell :: Maestro Publishing Member Team Mach-II :: Member Team Fusion http://blog.maestropublishing.com Create boilerplate beans and transfer objects for ColdFusion! Fire up a cup of Rooibos! http://rooibos.maestropublishing.com/ ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to cfcdev@cfczone.org with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/cfcdev@cfczone.org