Whoops its not tostring that takes something out of base64. Its decode().
I have a template that I built up years ago from the CF example that
displays a bunch of different ways to skin this cat. You can pick it
apart to bulletproof your use of CF encryption.
<CFSET variables.mystring=CreateUUID()>
<CFSET variables.tempstring=CreateUUID()>
<CODE>
<HTML><HEAD><TITLE>Encrypt Example</TITLE></HEAD><BODY>
<H3>Encrypt Example</H3>
<P>This function allows for the encryption and decryption of a
string. Try it out by entering your own string and a key of your
own choosing and seeing the results.
<CFIF isdefined ("url.Action")>
<CFSET string = FORM.myString>
<CFSET key = FORM.myKey>
<CFSET encrypted = encrypt(string, key)>
<CFSET urlencrypted = URLEncodedFormat(encrypt(string, key))>
<CFSET base64encrypted = ToBase64(encrypt(string, key))>
<CFSET UrlBase64encrypted = URLEncodedFormat(base64encrypted)>
<CFSET decrypted = decrypt(encrypted, key)>
<CFSET urldecrypted = URLDecode(urlencrypted)>
<CFSET urldecrypted = decrypt(urldecrypted, key)>
<CFSET dbsafedecrypted =
decrypt(tostring(tobinary(base64encrypted)),key)>
<CFSET urldbsafedecrypted = URLDecode(urlbase64encrypted)>
<CFSET urldbsafedecrypted =
decrypt(tostring(tobinary(urldbsafedecrypted)),key)>
<CFOUTPUT>
<UL>
<LI><B>The string:</B> #string#</LI>
<LI><B>The key:</B> #key#</LI>
<LI><B>Encrypted in normal format:</B> #encrypted#</LI>
<LI><B>Encrypted in URLEncodedFormat:</B> #urlencrypted#</LI>
<LI><B>Encrypted in Base64 format:</B> #base64encrypted#</LI>
<LI><B>Encrypted in UrlEncoded Base64 format:</B>
#urlbase64encrypted#</LI>
<HR WIDTH="80%">
<LI><B>Decrypted from normal format:</B> #decrypted#</LI>
<LI><B>Decrypted from UrlEncoded format:</B> #urldecrypted#</LI>
<LI><B>Decrypted from Base64 format:</B> #dbsafedecrypted#</LI>
<LI><B>Decrypted from UrlEncoded Base64 format:</B>
#urldbsafedecrypted#</LI>
</UL>
<FORM ACTION="#cgi.script_name#?Action=1&ssn=#urlbase64encrypted#"
METHOD="post">
Input your key:<BR>
<INPUT TYPE="Text" NAME="myKey" VALUE="#form.myKey#" SIZE="40">
<P>Input your string to be encrypted:<BR>
<textArea NAME="myString" cols="40" rows="5"
WRAP="VIRTUAL">#form.myString#</textArea>
<P>Here's an html link with the base64 urlencoded string:<BR>
<textArea NAME="myLink" cols="40" rows="5" WRAP="VIRTUAL"><A
HREF="http://mydomain/mypage.cfm?ssn=#urlbase64encrypted#">Click
Here</A></textArea><BR>
Here's another UUID: #variables.TempString#
</CFOUTPUT>
<CFELSE>
<cfoutput><FORM ACTION="#cgi.script_name#?Action=1"
METHOD="post"></cfoutput>
Input your key:<BR>
<INPUT TYPE="Text" NAME="myKey" SIZE="40">
<P>Input your string to be encrypted (this is a UUID):<BR>
<textArea NAME="myString" cols="40" rows="5"
WRAP="VIRTUAL"><CFOUTPUT>#variables.MyString#</CFOUTPUT></textArea><BR>
Here's another UUID: <CFOUTPUT>#variables.TempString#</CFOUTPUT>
</CFIF>
<BR><INPUT TYPE="Submit" VALUE="Encrypt my String">
</FORM></CODE></BODY></HTML>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:219271
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54