I'm trying to encrypt a string with encrypt and generatesecretkey..
I'm passing the string as a URL variable and then trying to decrypt
the string. I'm getting errors like
* An error occurred while trying to encrypt or decrypt your input
string: Input length must be multiple of 8 when decrypting with padded
cipher.
* The key specified is not a valid key for this encryption: Invalid
key length: 7 bytes.
I'm using it to allow users to reset their passwords.
What's weird is that the code works the majority of the time. We only
see the error every now and then.
What I do is on the forgot page I generate a secret key and then I
encrypt the user's ID and then URLEncode them to pass within a link.
<cfset sk = GenerateSecretKey("DES") />
<cfset id = encrypt(member.new_id, sk ,"DES","Base64")>
<cfset sk = URLEncodedFormat(sk) />
<cfset id = URLEncodedFormat(id) />
The link is sent to the user and the user clicks on it and is taken to
the reset page
I pass the values in a form
<input type="hidden" name="sk" value="<cfoutput>#url.sk#</cfoutput>" />
<input type="hidden" name="id" value="<cfoutput>#url.id#</cfoutput>" />
And then I decrypt the string so I can find the user's ID:
<cfset myid = decrypt(urldecode(form.id),urldecode(form.sk),"DES","Base64") />
So why is this generating an error sometimes?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347225
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm