This content has been marked as final. Show 8 replies
Is the leading zero disappearing from your 10 digit numeric data or your encrypted Hexidecimal string? Have you tried encrypting / decrypting a test number in the same CF page to see if you're losing the digit as part of the encryption process or the DB?
I just tried the code below and it isn't dropping the leading 0.
Have you dumped out the value before going into the query? That will isolate the problem to either your encryption or your query.
Post a snippet of how you're using encrypt/decrypt and maybe we can get a better idea of the problem.
<cfset key = GenerateSecretKey("AES")>
<cfset clearNum = "0123456789">
<cfset eNum = encrypt(clearNum,key,"AES","Hex")>
<cfset dNum = decrypt(eNum,key,"AES","Hex")>
I know you are using cf_varchar in your cfqueryparam but what datatype is the field you are inserting it into? If that is not a varchar then that'll be your problem!
This could be a workaround: If the value after the decrypt is not 10 digits, add leading zeros until it becomes 10 digits.
I dumped everything and even tested new numbers and I got it working on my local (testing) system that shares the same DB as our staging area. I've uploaded to the staging area all the pages I worked on however the leading zero's are still not being displayed on the staging area. Very strange.
I'm not sure where to go from here.
So you are using the same DB in both cases? Hmmm... Are you using different versions of CF on your development machine and your staging area? Worst case scenario, I'm thinking jdeline's suggestion is a pretty good hack to fix your issue.
We are using the same version of CF on both sites. The only possible problem that I can see by procedurally changing the display of the digits to ensure that it's ten digits long is that we use those digits for processing other items. I will have to look into that.
So you're using the save version of cf AND the same version of DB? And you're still getting different results on the 2 systems? Can you post the code that you use to encrypt / decrypt your 10 digit string?
I don't think jdeline was suggesting just changing the display of the digits to format it as a 10 digit number - I believe he was suggesting to add the leading zeros as soon as you decrypt the number. The only way I could see this being a problem is if you use the number in a system outside of CF (Java, .NET) before you have a chance to add the leading 0's.