How do I get the source binary from a hash function in ColdFusion 9?

In ColdFusion 9, I hash a string like this:, hash("bob", "SHA1")

I need it to return binary instead of a hex string.

+3


source to share


2 answers


Since you know the hashed string is in hex, just decode it using the label of the binaryDecode () function .



hashedString = hash("bob", "SHA1");
binaryData = binaryDecode(hashedString , "Hex");

      

+3


source


Is this something like after?

<cfscript>
s = "G'day World";
hash1 = hash(s, "SHA-1");
bin = binaryDecode(hash1, "hex");
hash2 = binaryEncode(bin, "hex");

writeDump(variables);
</cfscript>

      

output of code



Docs:

+1


source







All Articles