Robert Connolly robert at
Sat Sep 16 16:00:15 PDT 2006

On Saturday 16 September 2006 05:44, Jan Dvořák wrote:
> Why don't build OpenSSL sooner and make them use it instead?

OpenSSL's md5 could replace Coreutils' md5sum with a shell script. OpenSSL and 
md5sum have slightly different output however:

$ openssl md5 TODO
MD5(TODO)= d288fb95096befbea9c5d14b46ea7ddb

$ md5sum TODO
d288fb95096befbea9c5d14b46ea7ddb  TODO

$ echo foo |openssl dgst -md5

$ echo foo | md5sum
d3b07384d113edec49eaa6238ad5ff00  -

I don't know why Coreutils adds the trailing "-". Also, openssl doesn't have a 
built in --check option, so the script would have to do it. The script would 
also have to arrange openssl's output to mimic md5sum so .md5sum files are 
usable on other systems.

Something like:

foreach file in $? do
 if test -f $file; then
 md5sum=$(openssl md5 < $file)
 echo "$md5sum  $file"

I'm not much of an sh scripter. I think a shell script would be better than 
patching Coreutils to use libcrypto. OpenSSL also supports a few other digest 
algorithms. A single script could have md5sum/sha1sum/ripemd160sum symlinks 
to it, using:

hash=$(echo ${0##*/} | sed 's/sum//')
openssl $hash < $file

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <>

More information about the hlfs-dev mailing list