Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

Use CF built in "Hash" function. It takes the following format:

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

The following works:

<cfscript>
    val = 1117;
    md5 = Hash(val, "MD5");
</cfscript>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top