Related Post

.

Tuesday, 13 September 2011

What is MD5 Hash and How to Use it?



In this post I will explain you about one of my favorite and interesting cryptographic algorithm called MD5 (Message-Digest algorithm 5).This algorithm is mainly used to perform file integrity checks undermost circumstances. Here I will not jump into the technical aspects ofthis algorithm, rather will tell you about how to make use of thisalgorithm in your daily life. Before I tell you about how to use MD5, Iwould like to share one of my recent experience which made me startusing MD5 algorithm.

Recently I made some significant changes and updates to my website andas obvious I generated a complete backup of the site on my server. Idownloaded this backup onto my PC and deleted the original one on theserver. But after a few days something went wrong and I wanted torestore the backup that I downloaded. When I tried to restore thebackup I was shocked! The backup file that I used to restore wascorrupted. That means, the backup file that I downloaded onto my PCwasn’t exactly the one that was on my server. The reason is that thereoccured some data loss during the download process. Yes, this dataloss can happen often when a file is downloaded from the Internet. Thefile 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 itiscompletely necessary that you check the integrity of thedownloadedfile. That is you need to ensure that the downloaded file isexactlythe same as that of the original one. In this scenario the MD5hash canbecome handy. All you have to do is generate MD5 hash (orMD5check-sum) for the intended file on your server. After you downloadthefile onto your PC, again generate MD5 hash for the downloadedfile.Compare these two hashes and if it matches then it means that thefileis downloaded perfectly without any data loss.

A MD5 hash is nothing but a 32 digit hexadicimal number which can be something as follows


A Sample MD5 Hash
e4d909c290d0fb1ca068ffaddf22cbd0

This hash is unique for every file irrespective of it’s size andtype. That means two .exe files with the same size will not have thesame MD5 hash even though they are of same type and size. So MD5hash can be used to uniquely identify a file.


How to use MD5 Hash to check the Integrity of Files? 
Suppose you have a file called backup.tar on yourserver. Before you download, you need to generate MD5 hash for thisfile 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. Afteryou download this file onto your PC, you can cross check it’s integrityby again re-generating MD5 hash for the downloaded file. If both thehash matches then it means that the file is perfect. Otherwise it meansthat the file is corrupt. To generate the MD5 hash for thedownloaded file on your Windows PC use the following freeware tool

DOWNLOAD IT

I hope you like this post. For further doubts and clarifications please pass your comments. Cheers!
  
SOURCE: My 1st Website

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Adverts

BannerAd BannerAd BannerAd BannerAd