Activity Workshop
 

Md5

Md5 is a checksum function often used for verifying downloads. As well as the download file, often the server publishes the expected Md5 checksum for the file, so that you can check that the file you've downloaded is correct and hasn't accidentally been corrupted along the way.

But of course you need a way to generate the Md5 checksum from your file in order to compare it. There are plenty of platform-specific tools which can do this for you, for example the unix command line tool md5sum, but this platform-independent alternative can be handy if you haven't got such a tool available.

This Md5 checker is based on java, so you'll need a java runtime (at least version 5) in order to run it.

Download

Jar file

Runnable code plus source code (16 kb)
md5.jar - Complete tool including source code

Running

This checker tool is run from the command line (or console). The simplest way to call it is to just give it the filename of the file to check:

java -jar md5.jar path/to/file

This will generate the checksum and display it.

A second way to call it is to also give it the expected checksum (for example, copy-pasted from the website from which you downloaded the file):

java -jar md5.jar path/to/file expectedchecksum

This will generate the checksum and display it, and then compare it with the checksum entered. So you don't have to match it by eye, you'll get an immediate "MATCH" or "FAILED" message to tell you whether it was correct or not.

The third and final way to call this checker tool is to give it a file containing a list of checksums. For example, if a particular website offers 10 files for download, it might publish the md5 sums in a separate checksums.txt file which contains each of the 10 filenames and the corresponding checksums. If this md5 checker tool is given this file, it can look up the checksum in the file and compare it with the checksum just generated:

java -jar md5.jar path/to/file checksumfile.txt

This will generate the checksum and display it, and then compare it with the checksum found in the file. Again, it will display an immediate "MATCH" or "FAILED" message depending on whether it is equal or not.