I'm trying to replicate a function in Coldfusion that returns a string. The function looks like this:
<cffunction name="createKey" access="public" output="false" returntype="string" hint="Creates a propper ecryption/decryption key from a string.">
<cfargument name="thePassword" type="string" required="yes">
<cfargument name="algorithmType" type="string" required="no" default="MD5">
<cfargument name="binaryEncodeType" type="string" required="no" default="Hex">
<cfset var theKey = Hash(ARGUMENTS.thePassword,ARGUMENTS.algorithmType)>
<cfset theKey = ToBase64(BinaryDecode(theKey, ARGUMENTS.binaryEncodeType))>
<cfreturn theKey>
</cffunction>
The string this returns is a key value, so I must get an identical matching value from the new .Net function.
This .net equivalent for this line works fine:
<cfset var theKey = Hash(ARGUMENTS.thePassword,ARGUMENTS.algorithmType)>
Replicating this, however:
<cfset theKey = ToBase64(BinaryDecode(theKey, ARGUMENTS.binaryEncodeType))>
Is proving to be difficult. I get that it's decoding the hash and converting it to Base64, but the BinaryDecode function in CF takes "Hex" as a decode type. Any ideas how I might do this in .NET and get a string value identical to what I would get in Coldfusion?