Cryptographic hash functions take an input of arbitrary length and produces a message digest that is of a fixed, short length.The digest is called the “hash” of the input.In cryptographic hash function,instead of encrypting the whole message with the secret key, only the message digest is encrypted.
Algorithms used for determine the cryptographic hash of a message is MD5 and SHA1
MD5 Message-Digest Algorithm is a widely uses cryptographic hash function that produces a 128-bits hash values.It is commonly used in security applications and also used for checking the data integrity.It is not suitable for applications like digital signature and ssl certificate.
SHA1 is stands for Secure Hashing Algorithm.This is the most widely used of the existing SHA hash functions, and is used in several applications and protocols.
How to find the data integrity using cryptographic hash function
Basic Steps:
Create a file
Create a file with some content in it.
For example out.txt
Finding Cryptographic Hash function using MD5
Execute the following command in the terminal
$ md5sum <file_name.txt>
Output of this file is a hash value.For out.txt i got
2196fb4aea7a750b32eb3c9abcedc89b out.txt as its hash value.
Checking the integrity using MD5
Make some modification in the file that we are created.And calculate the hash value using MD5.For a small variation in the data,we can seen that the hash value is changed.
For example:When i change the content in out.txt, the corresponding hash value i got was
f00755d751964fddf6196f047fc674ea out.txt
Finding Cryptographic Hash function using SH1
sha1sum <file_name.txt>
The above command generate the cryptographic hash value.
The cryptographic hash function for out.txt is
7011dd2d9ad3e336c727683ac2031825e1721021 out.txt
Checking the integrity using SH1
After modifying the file and again calculate the hash function using SH1.For out.txt we got the value 50544c5dd3218b1be60ad15479ac6e06cefd2234 out.txt
From this 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.So this cryptographic hash function is used to check the data integrity.