A LONG while back I was testing the Hash function of ColdFusion 10 (during the Beta program) and I wrote a small test script to let me quickly check all the Hash algorithms. I did the same thing when I was testing the Encrypt and Decrypt functions to and I posted that script in this post. As I was sifting through scraps of code to I saw the Hash test script I wrote and figured I should share that one too.
This little snippet of code lets you test with the MD5 and the various strengths of SHA hashes. It also has the default CFMX_COMPAT algorithm that you should NEVER use. Additionally MD5 has been proven hackable and is reversible in many cases with rainbow tables.
I believe these are all ColdFusion 9 and up, but I may be wrong. It's been a while and I don't remember.
So I hereby set this code free into the wind!
<cfparam name="form.hashType" default="">
<form action="hash.cfm" method="post">
Data to Hash:<cfoutput><input type="text" name="data" value="#form.data#" size="40"></cfoutput><br />
Method:<select name="hashType" size="1">
<option value="CFMX_COMPAT"<cfif form.hashType eq "CFMX_COMPAT"> selected</cfif>>CFMX_COMPAT</option>
<option value="md5"<cfif form.hashType eq "md5"> selected</cfif>>MD5</option>
<option value="sha"<cfif form.hashType eq "SHA"> selected</cfif>>SHA</option>
<option value="SHA-256"<cfif form.hashType eq "SHA-256"> selected</cfif>>SHA-256</option>
<option value="SHA-384"<cfif form.hashType eq "SHA-384"> selected</cfif>>SHA-384</option>
<option value="SHA-512"<cfif form.hashType eq "SHA-512"> selected</cfif>>SHA-512</option>
<input type="submit" name="submit" value="Hash This">
<cfif Len(trim(form.data)) and Len(trim(form.hashType))>
#form.data# encrypted with #form.hashType# is<br />
*Note: When I write little tools like this I'm usually writing it because there is something I absolutely need to see in order to complete another project. These little tools are not written as projects themselves and therefore may not be very pretty or as full featured as something that I was writing as a complete project. I just needed to get some code running that gave me back the data I needed to see. There are no warranties or promises. If you find is useful then great. If not, oh well. I know the code works on CF9 at the moment. I can not be certain if it still works on other versions of ColdFusion. * Any code posted may not be totally secure or production ready. Use at your own risk. ** Unless otherwise noted, this code shall be deemed Public Domain.