Thursday, September 16, 2010

Cryptography - Hash generators & comparing hashes

Hash
One of the basic algorithms of cryptography is the hashing algorithm. Given an original block of message the algorithm will generate a hash that is unique for this particular message.
Advantage of a hash is that it is not feasible to compute the original message by reverse calculating the hash.
A common use of a hash is to check the integrity of a message. As an example ATMs use the hashed password stored on the card and the entered password hashed to validate the user.

MD5Deep
This is a set of programs to compute various hash keys for a given input file or files.

Create the input message
Create a word file with the text "Now is the time for all good men to come to the aid of their country".

Save the file


Create a hash
Execute md5deep and provide the above file name as it's input.
md5deep g:\csinfo\itc358\assessment2\country.docx
The generated hash key will be displayed. The length of the hash created is 128 bits or 16 bytes. The value shown is in 32 hexadecimal characters.



Create a hash
Use the md5deep documentation file as input to create another hash.
The length of the hash created is 128 bits or 16 bytes. The value shown is in 32 hexadecimal characters. This conforms to the requirement of a good hash algorithm to generate a consistent hash value regardless of the content length used to generate the hash.




Modify the message contents
Open the word file created as input to hash 1 and modify it by removing the fullstop at the end of the sentence.


Create a hash using the modified word file
Even the slightest modification has resulted in creating a completely new has value.
This proves the hash function can be used to check the integrity of a message.

Create a hash using sha1deep
The hash value length is 160 bits or 20 bytes long for both documents but the hash value is significantly different for the two documents.
Create a hash using sha256deep
The hash value length is 256 bits long for both documents but the hash value is significantly different for the two documents.

Create a hash using whirlpooldeep
The hash value length is 512 bits long for both documents but the hash value is significantly different for the two documents. The displayed hash value is in 128 hexadecimal digits.

No comments:

Post a Comment