How can I get the MD5 hash in ColdFusion?

I am trying to get a hash of MD5 value in ColdFusion. I tried this code using Encrypt function 1 :

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

But I get an error message:

The MD5 algorithm is not supported by the security provider that you selected.

How to choose another security provider?


1 Yes, I know that MD5 is not an encryption algorithm, but ColdFusion people do not seem to know this because they list it as a supported algorithm for the encryption function. Edit : I did not see the built -in Hash function , but I saw that encryption lists md5 and sha as supposedly supported algorithms, so I thought (it turns out wrong) that this is how you got the hash in CF.

+6
security coldfusion hash md5
source share
2 answers

If you want a hash, you shouldn't try hash functions in ColdFusion? I end up using SHA or SHA-256 algorithms, but MD5 should work with this function.

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

I would only use encryption if you want to decrypt later. For things like passwords, you don't want to decrypt them to use a hash function instead.

+14
source share

Use CF built into the hash function. It accepts the following format:

 Hash(string [, algorithm [, encoding ]]) 

The following works:

 <cfscript> val = 1117; md5 = Hash(val, "MD5"); </cfscript> 
+7
source share

All Articles