What is MD5 algorithm?
MD5 which stands for Message Digest algorithm 5 is a widely used cryptographic hash function that was invented by Ronald Rivest in 1991. The idea behind this algorithm is to take up a random data (text or binary) as an input and generate a fixed size “hash value” as the output. The input data can be of any size or length, but the output “hash value” size is always fixed.
whatever the input size you give, the algorithm generates a fixed size (32 digit hex) MD5 hash
Applications of MD5 Hash:
when a file is downloaded from the Internet. The file can be corrupted due to any of the following reasons:
Data loss during the download process, due to instability in the Internet connection/server.
The file can be tampered due to virus infections or
Due to Hacker attacks.
So, whenever you download any valuable data from the Internet, it is completely necessary that you check the integrity of the downloaded file. That is, you need to ensure that the downloaded file is exactly the same as that of the original one. In this scenario, the MD5 hash can become handy. All you have to do is generate MD5 hash (or MD5 check-sum) for the intended file on your server.
After you download the file onto your PC, again generate MD5 hash for the downloaded file. Compare these two hashes and if they match, that means the file is downloaded perfectly without any data loss.
A MD5 hash is nothing but a 32 digit hexadecimal number which can be something as follows:
e4d909c290d0fb1ca068ffaddf22cbd0
This hash is unique for every file irrespective of its size and type. For example, two different executable files (.exe files) with the same size will not have the same MD5 hash even though they are of same type and size. So MD5 hash can be used to uniquely identify a file. The same thing applies even for messages where each message that was sent and received can be verified using the MD5 hash.
How to use MD5 Hash to check the Integrity of Files?
Suppose you have a file called backup.tar on your server. Before you download, you need to generate MD5 hash for this file on your server. To do so use the following command:
For UNIX:
md5sum backup.tar
When you hit ENTER you’ll see something as follows:
e4d909c290d0fb1ca068ffaddf22cbd0
This is the MD5 hash for the file backup.tar. After you download this file onto your PC, you can cross check its integrity by again re-generating MD5 hash for the downloaded file. If both the hash matches then it means that the file is perfect. Otherwise it means that the file is corrupt.
Comments
Post a Comment