Verify files using MD5

How can you verify the integrity of some files as simple as possible? How can you check for manipulations or transmission failures? The question is answered quite simple: Checksums. One of the most common checksum techniques out there is MD5 which stands for Message Digest Version 5.

The fine thing about md5 is, that it’s just a checksum over a file that stays the same as long as the file does. Even some minor changes give you a complete different checksum.

Let’s get down to work with a practical example. I’m using our important text file named ‘test.txt’ having our famous ‘Hello World’ in it. The string itself should have e59ff97941044f85df5297e1c302d260 as md5 which I’m writing into the file check.txt for being able to automatically validate our file:

~ $ echo Hello World > test.txt
~ $ md5sum test.txt > check.txt
~ $ cat check.txt
e59ff97941044f85df5297e1c302d260 test.txt

We do know our checksum. Now we can validate it as a test:

~ $ md5sum -c test.txt.md5
test.txt: OK

But what happens, if we just change something really small? Let’s fire up a text editor and add a blank at the end of the message and check again:

~ $ md5sum notes.txt
f581daf4d74c8dc6d42bb442aa5a30be notes.txt

The automated validation says:

~ $ md5sum -c test.txt.md5
test.txt: FAILED
md5sum: WARNING: 1 of 1 computed checksum did NOT match

It’s all that simple…


Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.