Hi all,

I have a token that is being passed in via the URL, that is generated
in a .NET program. I am having trouble decoding it in CF 8 so I was
hoping that someone could give me a hand. I am very frustrated with
this as this is my first dive into AES.

The .NET developer gave me the following instructions:

These are the steps needed to return the key in the email back to it's
original state

1.       URLDecode the key
2.       Convert result to decoded base64 binary
3.       Remove chr(0) from end of string
4.       Decrypt from  AES192 (requires a 24 character Key).  Hence
make sure you pad the hash  key with spaces at the end up to 24
characters

And here is what I have code wise now (I changed the key to keep it private):

<cfoutput>
<!--- comes in via URL --->
<cfset 
forDec="OTg4MTc6NjcmOEpoXmRXRWY0JSVHWUcqb2xpa3VqZGxveHRvbkByZWQ1LmNvbS5hdQ%3D%3D">
<!--- padded with spaces to make 24 chars --->
<cfset key="7&KSK^8SID              ">
<br />#forDec#
<!--- 1. URLDecode the key --->
<cfset forDec = URLDecode(forDec)>
<br />#forDec#
<!--- 2. Convert result to decoded base64 binary --->
<cfset forDec = BinaryDecode(forDec,"base64")>
<!--- we now have binary object --->
<cfdump var="#forDec#">
<!---3. Remove chr(0) from end of string --->
<!--- I cant put a trim on to a binary object, nor can I do a
ReplacenoCase() --->

<!---4. Decrypt from  AES192 (requires a 24 character Key).  Hence
make sure you pad the hash  key with spaces at the end up to 24
characters--->
<cfset key = Decrypt(forDec,key,"AES","base64")>
</cfoutput>

This results in a bytearray cannot be converted to strings error. So I
tried forDec.toString(), but every request this generates a different
value - how can this be?

<cfset key = 
Decrypt(BinaryEncode(forDec,"base64"),BinaryDecode(key,"base64"),"AES","base64")>

Results in getting an error that " The input and output encodings are
not same."

I am at a loss and tearing my hair out - can anyone help me out here???

-- 
Duncan I Loxton
[EMAIL PROTECTED]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Check out the new features and enhancements in the
latest product release - download the "What's New PDF" now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:291078
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to