February 14, 2008
Verifying an md5 checksum using md5sum.txt
Tested on: Mac OS X and edubuntu 7.10
Geekiness: 4 / 5
Often when downloading a file you’ll see a companion optional download – an md5 checksum. That’s a way of verifying that the file you’ve downloaded hasn’t been altered in any way (say, to add a little command to email porn to your mother-in-law every Tuesday at 3am, or a nasty virus infecting you Windows users). Technically-speaking, it’s a one-way hash function – which means that it produces a string of characters from the input file. The function is set up in such a way that if a single part of the file changes, the string produced at the end will be quite different.
THAT all means that you have a way of verifying that you’re not downloading something which will wipe your hard drive at midnight (unless that’s what you’re into). Just run the downloaded file through the same program (called md5sum) and compare the result to the md5 checksum online. If they match, you’re good to go.
Here’s the command to run:
md5sum file-I-hope-isnt-an-evilly-manipulated-program.zip
This will give an output like:
24c1675e1c65e093c8238f77413ed9b2
Compare that to the online string…they should match.
Verifying md5 checksums can also be a useful way of verifying that the edubuntu cd you just burnt from the iso image has burnt properly. In this case, one of the burnt files is md5sum.txt – a list of the md5 checksums of each file on the cd. Verifying each file has burnt properly is a good idea, so that halfway through your new install it doesn’t crash and cause some mild ceiling-staring annoyance, punctuated by what my Dad calls “non-Presbyterian language”. I’ve learnt some cool words from my Dad! But now I use them less because of md5sum (I think there’s a t-shirt in there somewhere…).
So, this is what you do:
cd /cdrom
md5sum -c md5sum.txt | grep -v 'OK$'
If it spits anything out, then there’s a problem. This process has helped me realise my cd writer on my MacBook Pro doesn’t know how to properly write edubuntu cd’s…but luckily my G4 iBook does.
Comments(4)
Roger Saner is a web platform developer (using 

Did you install md5sum yourself under OS X? It looks like it ships with just ‘md5′.
Yes, you’re quite right – I installed md5sum as part of Fink, a genius way of bringing a lot of open source goodies to Darwin on the Mac platform. I’ve written a little bit more about Fink here.
But today I uninstalled fink and installed macports – because I wanted to start using svn.
If md5sum isn’t available, you can type
openssl md5 [filename]