Check MD5 Hash on your Mac

Oct 13, 2009 - 19 Comments

Mac Terminal icon

You can easily check the MD5 Hash of any file on your Mac, all you need to do is launch the Terminal and type the ‘md5’ command and point it at the file you wish to check the md5 has for.

How to Check MD5 Hash of a File on Mac

First launch the Terminal application, located in the /Applications/Utilities/ directory on the Mac. Next you’ll want to point the md5 command at the file you wish to check md5 hash for. For example, the syntax to check the MD5 hash of a file may look something like this:

md5 big_huge_file.iso

You’ll be returned with an MD5 Checksum Hash that you can check against the source MD5 code provided to you (or that a friend shares, you found online, or whatever).

An example of what the md5 hash will look is something like this:

MD5(big_huge_file.iso)= 20665acd5f59a8e22275c78e1490dcc7

The part after the = sign is the MD5 hash code that you can compare against the source to be sure that the file has retained it’s integrity through transmission. This is very handy when downloading large files, or if you want to make sure a file has not been modified, corrupted, or tampered with.

Terminal in Mac OS X

Checking MD5 Hash with openssl from the command line

Alternatively you can use the openssl command to check MD5 checksums on your Mac, like so:

openssl md5 big_huge_file.iso

The data returned to you will be the same whether you use the openssl command or the md5 command, it’s really just a matter of preference.

This simple md5 command works in Mac OS X and linux too, and it’s a simple way to verify what you are downloading or transferring has arrived intact.

.

Related articles:

Posted by: Bill Ellis in Command Line, How to, Tips & Tricks

19 Comments

» Comments RSS Feed

  1. Sgeio says:

    One way to check pragmatically the md5 signature is to type the following sequence of commands:

    md5 package_name.extension | grep hash_in_the_website_page

    Hope it helps

  2. Francesco says:

    Hy, guys
    if i launch the Terminal and type the ‘md5’ command i get an hash code while i use script shell (typing md5) in Automator i get a different hash……..
    Help me pls

  3. nic says:

    Hi Bill,

    I know it is a quite old thread but just wanted to thank you. Very useful.

    Regards

  4. flippy says:

    How could this be done recursively for the files on a DVD? Either into individual text files or in one text file for all video files.

    I would want to

    * generate hashes from DVD in drive
    * save a file to desktop

    later I would copy the files from not-encrypted DVD to documents

    * compare copied files hash to DVD files hash

    • uxhack says:

      On a mac? Use Terminal and a simple script in the OS.

      cd /path_inside_DVD_disk

      find . -type f -exec openssl md5 {} \; >> /tmp/output.txtfile @> &1 &

  5. mmmhate says:

    mmmm such hatred for ignorance. I suppose you lovely people also wisely hate oldtimey sms texting? Surely you don’t pay to use that legacy tech (either with money or via adware)…

  6. […] loop is usually best handled in a few different ways. Before beginning, you may want to check the md5 hash or SHA1 of the origin file if possible, that can easily tell you if the file was corrupted or is […]

  7. World's Fattest Man says:

    I am so fat i can’t check the MD5 of iAtkos L1.DMG

  8. Monberg says:

    Sweet! Coming to Mac from Windows i was a bit intimidated by the lack of all my usual (GUI) tools. But diving into the power of Term is a really rewarding experience. It sometimes makes me wish that i didn’t grow up with Windows…

  9. Petur says:

    I made a GUI program which does the same… http://itunes.apple.com/us/app/id465533447?mt=12

  10. fribbley says:

    hey DogsRULE: you’re an idiot. In a couple years, if you make it to high school you might learn about being a big boy and keeping your fool mouth shut when you have no idea what you’re talking about.

  11. Alex says:

    Yeah DogsRULE, you are right, there were a lot of people in the develop of the MD5, SHA1 (etc) hashes just for people to be able to download torrents.
    That’s the only use.

    I’ll give you another use, just to enlighten you, I use the MD5 to check on daily basis if my web site files were modified. This way, if there is a hacking attact to my site, I find out before Google banns my site.

    Another use? if you are making changing to your system, and want to know what files were changed by another process, you can relay on before/after md5 hashes

    Also, every piece of software available for download should publish a md5 hash or similar, so if you downloaded a whole Linux Distro, you can check if the download is good before you burn a DVD and try to install it.

  12. […] Mac’s checking the md5 hash is very easy, just use the md5 command line tool. You can do this on your Mac to check the md5 hash […]

  13. […] unofficially at 4% worldwideSnow Leopard Incompatible Software List from AppleMessiest Desktop Ever?Check MD5 Hash on your MacWarning! Obscure Snow Leopard bug deletes entire user accounts!MacBook Keyboard Backlight Controls […]

  14. […] more here: Check MD5 Hash on your Mac You can follow any responses to this entry through the RSS 2.0 feed. You can leave a […]

  15. Woodgie says:

    Nope, it isn’t.

    I regularly use it to check if 2 files that outwardly look the same (same size etc.) are actually the same. I’ll also use it (or to be more accurate, SHA1, the same as the hint above. Just substitute SHA1 for MD5 in the openssl command) as a quick and easy way to verify to people that attachments I’m eMailing them have not been tampered with. It’s the same basic theory as using a digital signature.

    Then you have http://support.apple.com/kb/DL930 and the like. Yep, Apple themselves use SHA1 (which is really just a ‘more accurate’ version of MD5 (yes, I KNOW how wrong that comment actually is!) to verify the contents of updates to the OS.

    It’s also used by online retailers and things like the Fink package manager. I could go on but I realise quite how boring I can be :-)

    So no, not just torrents.

  16. DogsRULE says:

    the only reason to use MD5 on a Mac is for torrents

    • henka says:

      thats just dumb, if you know how torrents work then you should know that files allready are checked. Each peace is checked seperately and the torrent-file has the hash for the full file

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site