What is MD5 Hash and How to Use it

What is md5 hash and how to use itIn this post, I will discuss about one of the interesting cryptographic algorithm called MD5 in a very simple and easy to follow manner. In addition to understanding what is MD5 hash, you will also learn how to make use of this algorithm in your daily life.

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. Here is an example of MD5 Hash function at work:

MD5-Hash Function Example

As you can see from the above example, whatever the input size you give, the algorithm generates a fixed size (32 digit hex) MD5 hash. You can even try this on your own using the MD5 hash generator tool here.

Applications of MD5 Hash:

Before I tell you about how to use MD5, I would like to share one of my recent experience which made me start using MD5 algorithm.

Recently I made some significant changes and updates to my website and as obvious, I generated a complete backup of the site on my server. I downloaded this backup onto my PC and deleted the original one on the server. But after a few days something went wrong and I wanted to restore the backup that I downloaded. When I tried to restore the backup, I was shocked! The backup file that I used to restore was corrupted.

That means, the backup file that I downloaded onto my PC wasn’t exactly the one that was on my server. The reason is that there occurred some data loss during the download process. Yes, this data loss can happen often 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:

A Sample MD5 Hash
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. To generate the MD5 hash for the downloaded file on your Windows PC use the following freeware tool:

I hope you like this post. For further doubts and clarifications, please pass your comments. Cheers!

48 Comments

  1. David
    January 19, 2010 at 6:47 PM

    Hello…you Really Rock ! Can i ask u 1 q? do u know how to make a good template for a blog? please reply


  2. Karan Kapoor
    January 20, 2010 at 7:13 PM

    I am great fan of urs Srikanth


  3. funcky
    January 20, 2010 at 9:32 PM

    Is that “md5sum” inbuilt command ?
    Or have to install any extra packages?
    And another thing is that will it work on linux?


    • Srikanth
      January 21, 2010 at 12:23 PM

      @ funcky

      MD5SUM is inbuilt on all UNIX systems. However on Windows your need to install the package. The download link is given in the post itself.


  4. Abhijeet
    January 31, 2010 at 10:53 AM

    Hi!Thanks for giving lot of knowledge


  5. Abhijeet
    February 14, 2010 at 1:48 PM

    Thanks Srikanth for such a wonderful tip…but the download link is not working…


  6. ankit
    April 3, 2010 at 5:26 PM

    hi i really like your article


  7. AryaN
    April 16, 2010 at 11:33 PM

    hey dude…bt hw 2 decrypt d encryptd code….???


  8. xDjura
    April 17, 2010 at 2:24 PM

    Thanks alot ur hacks are great!


  9. SNS
    April 19, 2010 at 6:22 PM

    Thz for the post.;…:)


  10. Karthick
    May 3, 2010 at 2:13 PM

    Very nice information :)


  11. Faizal
    May 14, 2010 at 9:35 PM

    Hi sri, i have one doubt , can we convert MD5 hash to a real string(text) , that should be the same used to convert MD5


    • Srikanth
      May 17, 2010 at 2:30 PM

      @ Faizal

      MD5 hash is reversible only when you know the method and the key used for encryption. Often this is kept secret and hence it’s not possible to reverse it back in most cases. If you know then you can decrypt (reverse) it back.


  12. rajul
    May 29, 2010 at 8:32 AM

    you rocks dude i have visited many hacking sites bt this is best awesome but i have problem in compiling file it tels so many errors


  13. aditya snehil
    May 31, 2010 at 1:11 PM

    how to decrypt md5 hash….


  14. Themsay
    June 18, 2010 at 6:35 PM

    Sir ur posts has been a guide and I love it so much.
    I too still ‘ve a problem on compiling file to exe? pls, where u said cd command has been my problem. I need ur help thanks.


  15. MD5 Hash
    June 24, 2010 at 1:02 AM

    Hi Srikanth.
    Very good explanation. Just thought you’d like to know I’ve built a web tool for performing MD5 sums. You can use it here: http://www.md5hasher.net

    Regards


  16. nasir
    July 13, 2010 at 1:05 PM

    It is really awsome post about md5 encryption security.Thanks a lot for this post.


  17. zint
    August 3, 2010 at 9:55 PM

    how to translate the code???is it any sofware can trnslate it…where?


  18. v.keerthika
    August 23, 2010 at 11:20 PM

    GOOD SRIKANTH YOU HAVE POSTED WONDERFUL EXPALNTION FOR MD4 AND ANSWERS FOR QUERIES


  19. Phil Lester
    September 4, 2010 at 5:35 AM

    How can I use MD5 or SHA1 to to generate a hash value for an entire folder or even a jump drive.
    Phil


  20. magesh kumar
    September 7, 2010 at 10:24 AM

    Thanks dude……….really greatttttttt


  21. Sid
    October 29, 2010 at 11:45 AM

    You are totally awesome dude!! i just love reading your posts. Keep writing more.


  22. DIPESH
    December 14, 2010 at 11:03 PM

    Really,you are GOD of hacking.


  23. faraaj
    December 18, 2010 at 9:13 PM

    it’s really incredible. You guys are making technology move to its limits.
    Am glad that your making things easier.
    Thanks………….

    Mr. faraaj sulaimam


  24. Acid_Demons
    February 23, 2011 at 1:42 AM

    nice skills srikant i depreciate u, i just wanted to ask that how can we get the password of “abc@gmail.com” in the form of md5 hash is it possible? i know how to crack that hashes just i dont know is how to get that hashes


  25. Mothilal
    March 22, 2011 at 2:01 PM

    need help..

    I am sending a file from one server to remote server through sftp.

    they(remote server peoples) gave one MD5 Hash string to me.it contains 32 characters(alphanumeric).

    what can i do with this MD5 Hash string?

    how this MD5 hash string will be use in sending file?

    pls advice me

    Thanks in advance


  26. AnKit AGgarwal
    April 14, 2011 at 8:24 PM

    i loV u sir … u dnt knw i m really inspired by u …
    plzz tl me if ther is any good online couce on internet security or ethical hacking .. ?
    m waitin fr ur rpl … thnk u ….


  27. john
    April 17, 2011 at 3:44 AM

    really greate …i also got in same trouble


  28. kun
    October 25, 2011 at 6:04 PM

    as it possible to decrypt md5 password if possible then tell me how??????????


  29. george
    November 3, 2011 at 8:43 PM

    how to decrypt an md5 password?


  30. biki
    March 8, 2012 at 3:51 PM

    Hi Shrikant your posts are really amazing…bt I lik to know about Rainbow Hacking..pls make an article on Rainbow hacking…thnx in advnce…


  31. Philip Whitehouse
    August 22, 2012 at 5:05 PM

    “This hash is unique for every file irrespective of it’s 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.”

    This is wrong.

    1) It’s impossible to iterate every possible file and have each one with a fixed length hash.
    Proof:
    File 1: Contents “1″: Hash #1
    File 2: Contents “2″: Hash #2
    etc
    File hashcombinations+1: No available hash

    2) MD5 is broken. It’s not collision resistant.


  32. mAuLiK patEl
    December 22, 2012 at 9:27 AM

    @Srikanth

    How To Use Md5? Plz..Help Me>>


    • Neelima
      August 2, 2013 at 12:03 PM

      MD5 hash is reversible only when you know the method and the key used for encryption. Often this is kept secret and hence it’s not possible to reverse it back in most cases. If you know then you can decrypt (reverse) it back.

      Please tell me the procedure to reverse(decrypt)the text from md5 hash


  33. teenu
    January 18, 2014 at 10:19 PM

    Am an engg student. am doing my project n cloud security. so i need to knw the data on cloud s secured using md5 passwrd encryption. reply soon sir.. i am waiting


  34. ruby
    February 20, 2014 at 12:07 PM

    Short and Precise :)


  35. Leena
    March 3, 2014 at 5:03 PM

    wow!!! you have put in very simple words.
    BEST!!!


  36. vivesh
    March 22, 2014 at 2:38 PM

    hello sir

    i am vivesh and i want learn hacking
    you take me some general knwndge which is helpful to me


  37. Krazyhack3r
    April 1, 2014 at 3:21 PM

    I know its very easy to break. So less secure but still its using in Many Applications

    -Krazyhack3r


  38. Mark
    April 4, 2014 at 10:42 AM

    Great info!

    I developed a little program for Macintosh OSX computers called Hasher.

    This program can be used on a Mac to do what you suggest without the terminal.

    Hasher can make hashes from files and text input.

    Everyone is welcome to try it out.

    http://marks-design.com/Hasher-for-mac.html


  39. Mohit Bumb
    April 11, 2014 at 2:48 PM

    Best encryption for passwords and nobody can crack it until he have list of original password.


  40. Rc
    May 10, 2014 at 7:44 PM

    Do U Know Any Technique To Encrypt Batch Virus ViA Hash


  41. suman
    May 26, 2014 at 8:57 AM

    hello sir i am suman i learn hacking plz learn to me


  42. Shubham
    June 3, 2014 at 2:48 PM

    sir a detailed tutorial is required as far as decryption is considered….


  43. sk
    June 4, 2014 at 5:45 PM

    wow it is an interesting keep it up!
    let me ask u one Q
    how can we compare two executable files or executable file with managed library in a C# project i hope u will help me.


  44. Ben
    June 20, 2014 at 11:27 PM

    There is also a downloadable tool from MS for Windows to do command line md5 called “fciv”. Helpful for us linux/unix folks that work with windows too:

    Microsoft File Checksum Integrity Checker
    http://www.microsoft.com/en-us/download/details.aspx?id=11533

    Screenshot:
    http://geekswing.com/wp-content/uploads/2014/04/windows_md5sum_sha1_example.jpg


  45. Ben
    June 20, 2014 at 11:29 PM

    Also, want to add that it’s good to know the security issues around md5. I use it all the time and for that reason looked at security concerns with it. Mainly, it is possible for two different files to have identical hashes, but

    1) both files need to be created by the same person
    2) you cannot “target” a hash
    and
    3) hashes have finite combos so by dumb luck it is possible to have a “collision” … probability is very low

    Check this out for more info:
    http://geekswing.com/geek/the-magic-of-hash-and-i-mean-of-the-md5-and-sha-1-vintage/


Leave A Reply