Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Encrypt works, decrypt doesn't

Guest
Sep 19, 2006 Sep 19, 2006
First, thanks for all the help available on here - these forums are a last resort that always provides an answer.
OK, on CF 6.1, I am encrypting a string thus before insert into SQL 2K DB:

<cfset Encrypted = Encrypt(Form.TREE_NUMBER, "treeroots")>
<cfset Form.TREE_NUMBER = #Encrypted#>

All goes OK there... when I look at the value in the table, it is there and looks encrypted. The trouble starts here:

<CFOUTPUT query="gettrees">

<cfset Decrypted = Decrypt(TREE_NUMBER, "treeroots")>
<cfset TREE_NUMBER2 = #Decrypted#>

Here's the weird part: this works on my local machine test version of CF 6.1, but on the production server (also 6.1) it produces this error:

15 null <br>The error occurred on line 23.

There is so little info available on CF encrypt and decrypt functions - does the seed have to be defined somewhere before it is used? Is it possible that the production server can't find the key? Where is it stored? Is my syntax bad? Please help - I need a simple encryption routine for some semi-sensitive data in the database that I need to later query and output to a text file for use.

Thanks!

426
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 19, 2006 Sep 19, 2006
encrypt can add some unusable characters to the stored string that might
not be reinterpreted correctly. So one way around that is to encode the
encrypted value.
encwd = URLEncodedFormat(Encrypt(stringtoencrypt, "yourkey"))
deval = Decrypt(URLDecode(valuefromdatabase), "yourkey")
HTH
--
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 24, 2006 Sep 24, 2006
LATEST
You have either to URLEncode the string prior to insert it into the DB, or use nvarchar fields instead of varchar fields to allow extender characters to be stored.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources