Search code examples
coldfusioncoldfusion-9sha

How to get raw binary from hash function in ColdFusion 9?


In ColdFusion 9, I am hashing a string like so: hash("bob", "SHA1"), I need it to return binary instead of a hex string.


Solution

  • Since you know the hashed string is in hex, simply decode it with the aptly named binaryDecode() function.

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