Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get an MD5 hash in ColdFusion?

I'm trying to get an MD5 hash of a value in ColdFusion. I tried this code using the Encrypt function1:

<cfscript>
val = 1117;
md5 = Encrypt(val, 0, "MD5", "Hex");
</cfscript>

But I get an error:

The MD5 algorithm is not supported by the Security Provider you have chosen.

How can I choose a different security provider?


1 Yes, I know that MD5 isn't an encryption algorithm, but the ColdFusion folks don't seem to know that because they list it as a supported algorithm for the Encrypt function. Edit: I didn't see the built-in Hash function but I saw the fact that Encrypt lists md5 and sha as supposedly supported algorithms, so I thought (incorrectly it turns out) that this was just how you got a hash in CF.

like image 490
Kip Avatar asked Oct 23 '09 15:10

Kip


People also ask

How do you find the MD5 of a string?

You can use md5sum command to compute and check MD5 message digest. This is a default tool on most modern Linux distributions. It generate a md5 hash for given string or words or filenames.

Is it possible to decode MD5?

The MD5 cryptographic algorithm is not reversible i.e. We cannot decrypt a hash value created by the MD5 to get the input back to its original value. So there is no way to decrypt an MD5 password.

What is MD5 formula?

The MD5 hashing algorithm uses a complex mathematical formula to create a hash. It converts data into blocks of specific sizes and manipulates that data a number of times. While this is happening, the algorithm adds a unique value into the calculation and converts the result into a small signature or hash.


1 Answers

If you are wanting a hash shouldn't you try the hash function in ColdFusion? I end up using the SHA or SHA-256 algorithms, but the MD5 should work using that function.

hash(saltTheHash & trim(UserPassword), "SHA")

I would only use encrypt if you are wanting to decrypt sometime later. For things like passwords, you don't want to decrypt them so use the hash function instead.

like image 88
Eddie Avatar answered Sep 25 '22 21:09

Eddie