You can also use: cfusion_encrypt() and cfusion_decrypt().

cfusion_encrypt() encrypts the text to numbers and it is DB safe.

Steve

Will Swain wrote:
> 
> Thanks Zach,
> 
> I'll have a look at that
> 
> Cheers
> 
> Will
> 
> -----Original Message-----
> From: Zachary S. Bedell [mailto:[EMAIL PROTECTED]]
> Sent: 05 April 2001 19:26
> To: CF-Talk
> Subject: RE: encrypt/decrypt
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> The values that the CF Encrypt function creates usually aren't safe to
> put into a database -- they're binary values if my memory serves
> correctly.  The error you're getting is because Decrypt throws an error
> if the value it gets isn't a valid value made by the Encrypt functions.
> 
> Before you put your values into the DB, you need to convert them to text
> only values.  URLEncodedFormat() would work.  ToString() would probably
> work too.  Then when you pull the value back out of the DB, you just
> URLDecode() it.  I'm not sure how you turn ToString() back to it's
> original form.  I thought it was ToBinary() or something, but I don't
> see that in my quickref book....
> 
> To guard against crashes b/c of modified, corrupted values, just
> surround your Decrypt() function call in a CF Try block & handle it
> accordingly.
> 
> <!--- Encryption: --->
> <Cfset Gibberish = URLEncodedFormat(Encrypt(Secrect, Password)>
> <cfquery name="DontTellAnyone" blah>
>         INSERT INTO Table (Secret) VALUES( '#Gibberish#'
> </cfquery>
> 
> <!--- Decryption: --->
> <Cfquery name="GetSecret" blah>
>         SELECT Secret
>         FROM Table
>         WHERE ...
> </cfquery>
> 
> <Cftry>
>         <cfset Secret = Decrypt(URLDecode(GetSecret.Secret), Password)>
>         <cfset DecryptOK = True>
>         <Cfcatch type="any">
>                 <cfset DecryptOK = false>
>         </cfcatch>
> </cftry>
> 
> <cfif DecryptOk>
>         <Cfoutput>The secret word is: #Secret#</cfoutput>
> <cfelse>
>         <cfoutput>Something broke...</cfoutput>
> </cfif>
> 
> Hope that's helpful.
> 
> Best regards,
> Zac Bedell
> > -----Original Message-----
> > From: Will Swain [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, April 05, 2001 7:16 AM
> > To: CF-Talk
> > Subject: encrypt/decrypt
> >
> >
> > Hi guys,
> >
> > Got an interesting one here. I am encrypting some details
> > before entering
> > them in a databse, then decrypting them as the authorised views them.
> >
> >
> > However, I am getting this error on decryption:
> >
> > Error Diagnostic Information
> >
> > An error occurred while evaluating the expression:
> >
> >
> >  decryptednumber = decrypt(encryptednumber, numberkey)
> >
> >
> >
> > Error near line 25, column 8.
> > --------------------------------------------------------------
> > --------------
> > ----
> >
> > The value to be decrypted is not valid
> >
> >
> > This is the code I have in that location. Interestingly,
> > decrtypting the
> > name doesn't seem to cuase a problem:
> >
> > <cfset numberkey = "eagles">
> >
> > <cfset namekey = "selhurst">
> >
> > <cfset encryptedname = #getdetails.name#>
> >
> > <cfset encryptednumber = #getdetails.number#>
> >
> > <cfset decryptednumber = decrypt(encryptednumber, numberkey)>
> >
> > <cfset decryptedname = decrypt(encryptedname, namekey)>
> >
> >
> > This is the code on another page that encrypts the values:
> >
> > <cfset numberkey = "eagles">
> >
> > <cfset namekey = "selhurst">
> >
> > <cfset encryptednumber = encrypt(value_number, numberkey)>
> >
> > <cfset encryptedname = encrypt(value_name, namekey)>
> >
> > Any ideas on this anyone??
> >
> > TIA
> >
> > Will Swain
> >
> >
> >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to