Home

Cryptographic hash is actually an algorithm. This algorithm takes in a block of data and returns a fixed value called as a hash value. For each block, the hash value is unique. The block of data on which cryptographic hashing is applied is called the message and the hash value is called the message digest. The most important use of message digest is in checking the integrity of a data. If a data is modified, the hash value changes.

Two algorithms used for finding the hash value of a message are MD5 and SHA1.

  •  MD5 : This a widely used hash function which returns a 128bit hash value. It is used in security applications for verifying whether a data is modified or not. MD5 is not collision resistant. It cannot be used in applications like digital signature or SSL certificates.
  •  SHA1 : SHA stands for Secure Hashing Algorithm.It is used several applications and protocols.

Now you’ll be wondering how to check the integrity of a data using hashing algorithms.This can be checked practically without taking much time. Follow these steps:

1.Create a file

Create a text file with some data in it. Let the file be ‘test.txt’.

2. Hashing using MD5

Execute the following command to get the hash value :

$ md5sum test.txt

The output of this command is the hash value. For my file, I got the hash value as 4544496e680003c3a6abfb0817b814be.

3. To check the integrity of the message using md5

Just modify your data a little bit and again apply the above command. On modifying my data I found the new hash value as  3f55041d9d20ce4acf6e42705aeb3989 . So you can see that the hash value has changed a lot for small change in the message. Thus you can find whether someone has manipulated a data or not.

4. Hashing using SHA1

To find the hash value using SHA1, do

$ sha1sum test.txt

On applying this command, I got the hash value as 4a336c695730143da08dc483af7e6f2b8b127cff.

5. To check the integrity Using SHA1

After modifying the file apply the hash fuction. I got the new hash value as 935f8c77c89dbfe6eb9ae9c81bb3525f94b4f2c6 .

So it is clear that even a small change in the data can identified by using the hash function. If the data is not modified the hash value remains the same.

Leave a comment