Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Work with MD5 checksums UNIX
Note: I don't feel very good about myself for having missed this one for so long, but I'm posting it in case the blindingly obvious may have escaped a few others as well.

Ever since switching to OSX, I've wondered why it didn't feature a way to do MD5 digests on files.

MD5 is a way to 'fingerprint' a file much like a hash or checksum. The MD5 algorithm is considered 'cryptographically secure' in that it produces a digest (usually represented as a string of hex digits) that is unique to a given file and is nearly impossible to duplicate by fiddling with the source file. In short, it's often used as a component in digital signature protocols and a way of verifying whether a file has been tampered with.

The built-in cksum command has an -m switch that is supposed to do just that, but appears to be broken. Of course, it would be trivial to download the sources for an external app (such as 'md5sum'), but it's always nicer to be able to do things with the tools supplied natively. Well, here it is:
openssl md5 myfile
or
openssl md5 < myfile
I'd completely forgotten that OSX comes standard with OpenSSL installed! Of course, it can do a LOT more than just message digests and is definitely worth investigation if you're interested in crypto.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[31,609 views]  

Work with MD5 checksums | 4 comments | Create New Account
Click here to return to the 'Work with MD5 checksums' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Alternate way
Authored by: THEM on Jul 07, '02 12:28:06PM

the command openssl dgst will create a md5 signature for input files.



[ Reply to This | # ]
ChekMate Preference Pane
Authored by: Palijn on Jul 08, '02 06:58:08AM
Be sure to check ChekMate from Brian Hill .
Is is a wonderful Preference Pane that automates the MD5 summing and differences checking of critical system files, as well as user-configurable lists of files.
It can be found here: http://personalpages.tds.net/~brian_hill/

HTH -- Palijn

[ Reply to This | # ]
make a shell script
Authored by: jimr on Jul 10, '02 05:39:52PM
here is a sample shell scipt that can help you to get the md5 checksum for any file. maybe as a "homework" assignment you can make it check the result against the md5 verification file that comes with many source packages....
(like adding cat $1.md5 if you have the files named like that...)


#!/bin/sh
#######################################
# find the md5 checksum of some file by name
# syntax: get_md5
# by jrc 7/2002
#######################################
mypgm=$1
if [ "$1" = "" ]; then
echo "No defaults"
echo "--------------------------------------"
echo "syntax: get_md5 "
echo "--------------------------------------"

else
openssl md5 $1
fi



[ Reply to This | # ]
md5 cmd now in 10.2
Authored by: victory on Sep 02, '02 10:27:29PM

Yep. It's /sbin/md5. See 'man md5' for more info.
(And yes, it *does* give the same results as 'openssl md5' :-)



[ Reply to This | # ]