Hash functions can be used to protect your data or entire files against tampering. Cryptographic hash functions are one-way-transfer-functions: This means: It is NOT possible to guess or calculate the input value based on the output value of such a function.
For example: You could create a hash when you receive a file and store the hash in a database. Whenever that file is retrieved, your code could hash the file again and compare the hash against the stored value. If different, something has manipulated your file. This is what personal firewalls and Intrusion Detection Systems do.
Other uses are many: Use hashes to store passwords - do not store the password but store its hash. This way, nobody could get passwords in plain text even if your system is compromised.
Why to want more than ColdFusion's built-in Hash function?
MD4 is weak and MD5 is no longer considered as secure enough. So, ColdFusion's own hash function is not sufficient for fingerprinting at an absolute secure level.
Besides this, ColdFusion's hash cannot be applied to files.
This tag is a wrapper to Hagen Reddmann's famous cryptographic library.
The following hash_test.cfm is also included in the retail zip and it shows the usage of this CFX tag. It is also executed if you follow the demonstration link.
*******************************************************************
<html> <head> <title>MindPower - Hashes Demo</title> </head>
<body bgcolor="silver">
<cfset source = now() & "The world is beautiful and needs caring by its children">
<cfset source_file = "c:cfusioncfxcfx_hashes.dll">
<cfoutput>
<br>
Source is "#source#" (##chars #Len(source)#)<br><br>
Source File is #source_file#<br><br>
<h1>Checksums over string</h1>
<cfx_hashes source="#source#" hash="CRC32" result="res"> CRC32 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source#" hash="CRC16_CCITT" result="res"> CRC16_CCITT = #res# (##chars #Len(res)#)<br>
<h1>Hashes over string</h1>
<cfx_hashes source="#source#" hash="MD4" result="res"> MD-4 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source#" hash="MD5" result="res"> MD-5 = #res# (##chars #Len(res)#)<br> CF MD-5 = #hash (source)#<br>
<cfx_hashes source="#source#" hash="SHA" result="res"> SHA = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source#" hash="SHA1" result="res"> SHA-1 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source#" hash="RIPEMD160" result="res"> RIPEMD160 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source#" hash="RIPEMD256" result="res"> RIPEMD256 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source#" hash="RIPEMD320" result="res"> RIPEMD320 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source#" hash="HAVAL160" result="res"> HAVAL160 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source#" hash="HAVAL256" result="res"> HAVAL256 = #res# (##chars #Len(res)#)<br>
<h1>Checksums over file</h1>
<cfx_hashes source="#source_file#" hash="CRC32" source_is_filename="Yes" result="res"> CRC32 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source_file#" hash="CRC16_CCITT" source_is_filename="Yes" result="res"> CRC16_CCITT = #res# (##chars #Len(res)#)<br>
<h1>Hashes over file</h1>
<cfx_hashes source="#source_file#" hash="MD4" source_is_filename="Yes" result="res"> MD-4 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source_file#" hash="MD5" source_is_filename="Yes" result="res"> MD-5 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source_file#" hash="SHA" source_is_filename="Yes" result="res"> SHA = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source_file#" hash="SHA1" source_is_filename="Yes" result="res"> SHA-1 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source_file#" hash="RIPEMD160" source_is_filename="Yes" result="res"> RIPEMD160 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source_file#" hash="RIPEMD256" source_is_filename="Yes" result="res"> RIPEMD256 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source_file#" hash="RIPEMD320" source_is_filename="Yes" result="res"> RIPEMD320 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source_file#" hash="HAVAL160" source_is_filename="Yes" result="res"> HAVAL160 = #res# (##chars #Len(res)#)<br>
<cfx_hashes source="#source_file#" hash="HAVAL256" source_is_filename="Yes" result="res"> HAVAL256 = #res# (##chars #Len(res)#)<br>
</cfoutput>
</body> </html>
|