You are here

MD5 "Message Digest" Utility

MD5 is an algorithm for generating a digital signature from a message of indeterminate length. It can be used as a form of encryption but is also useful for ensuring data has not been corrupted during transmission.

Under Mac OS X, the "md5sum" terminal command allows the generation and verification of md5 checksums. An md5 checksum file will typically have a ".md5" extension. To verify data integrity from an existing md5 file, issue the following terminal command:

$ md5sum -c 

Note that if the md5 file was created on a non-Unix (ie, Windows) machine, you may receive "file not found" errors. This is due to the difference in newline or end of line characters between operating systems. See the [MacOSXNewLine] page for details on how to fix this problem.

md5sum File Format

A properly formatted md5sum file for use with the above "-c" option contains a checksum, followed by TWO spaces, followed by the corresponding filename with that md5 checksum. For example, say we have a text file called "php5.md5" containing the following information:

cdf95cdc1ebccccce9c96653fd593dd4  php-5.2.13.tar.gz
4480d7c6d6b4a86de7b8ec8f0c2d1871  php-5.3.2.tar.gz

running md5sum -c php5.md5 would compare each checksum against the file listed on the same line and generate the following output, assuming the files are intact and untampered:

php-5.3.2.tar.gz: OK
php-5.2.13.tar.gz: OK

Any mismatches between a filename and corresponding checksum would be reported here as a checksum failure.