So, Ray helped me solve this via email and I thought I'd post the solution here for the good of the order:
The point of this exercise is that I have a table with a primary key that's a standard Microsoft GUID (36 hex characters long). This is fine but there's one remote "place" I need to store references to this primary key (via webservice) that'll only accept a max of 25 characters. So by base64'ing the GUID, I'll be able to use Microsoft's GUID and not break the webservice.
Problem is: CF's ToBase64 chokes on the decimal representation of a GUID (it's too big). So, luckily, I found this http://www.fusebox.org/forums/messageview.cfm?catid=21&threadid=5075 and used it to create this:
1
2<cffunction access="public" name="HexToBase64" output="yes" returntype="string">
3 <cfargument name="Hex" type="string" required="yes">
4 <cfset outStream = CreateObject("java", "java.io.ByteArrayOutputStream").init()>
5 <cfset inputLength = Len(Hex)>
6 <cfset outputString = "">
7 <cfset i = 0>
8 <cfset ch = "">
9 <cfif inputLength mod 2 neq 0>
10 <cfset Hex = "0" & Hex>
11 </cfif>
12 <cfloop from="1" to="#inputLength#" index="i" step="2">
13 <cfset ch = Mid(Hex, i, 2)>
14 <cfset outStream.write(javacast("int", InputBaseN(ch, 16)))>
15 </cfloop>
16 <cfset outStream.flush()>
17 <cfset outStream.close()>
18 <cfreturn ToBase64(outStream.toByteArray())>
19</cffunction>
Sweet. Then Ray helped me noodle the return voyage. (Unfortunately, CF does not have "FromBase64" or equivalent.)
1
2<cffunction access="public" name="Base64ToHex" output="yes" returntype="string">
3 <cfargument name="Base64" type="string" required="yes">
4 <cfset aBinary = ToBinary(Base64)>
5 <cfset Hex = "">
6 <cfloop index="i" from="1" to="#ArrayLen(aBinary)#">
7 <cfset Hex = Hex & FormatBaseN(BitAnd(aBinary[i], 255), 16)>
8 </cfloop>
9 <cfreturn Hex>
10</cffunction>
Hope this saves someone some time someday.
