I've only used the tobase64() function to encode image files into a string.
It took a couple trys before I got it to work right. I'd recommend you first
try and get CF to just encode the data, then decode it and make sure it's
returning back to normal. If it does that and it still doesn't work with the
other application, you're probably SOL.

Here's some sample code that is working in one of my applications (I've
stripped it down a bit).

<cffile action="" file="#expandpath(directory)#\#name#"
variable="filevariable">

<cfset filedata=tobase64(filevariable)>

<cfset binaryfile=tobinary(filedata)>

<cffile action="" file="#attributes.newdirectory#\images\#filename#"
output="#binaryfile#">

Steve

  _____  

From: Bob Jacoby [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 03, 2004 9:59 AM
To: CF-Talk
Subject: Base 64 encoding hexadecimal string

I need to hash a string using sha-1 and then base64 encode the result. This
is required to interoperate with another agency who's using java to do the
same.

We're hashing correctly and getting a hexadecimal string back (need hex
since may contain non-ascii characters). However, we can't feed the hash
result in to the tobase64 function because it interprets the hexadecimal
string as an ascii string. This means the 160 bit hash/40 length hexadecimal
string is interpreted by the tobase64 function to be a 320 bit string. The
encoding therefore doesn't result in a string 28 characters long (as it
should be), but 56.

Is there a CF tag that can properly base64 encode a hexadecimal string? Our
other alternative is to use java, which we can do, but I wanted to see if
there was a CF way first.

Thanks,
Bob

  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to