[olug] md5's

Mark A. Martin mmartin at amath.washington.edu
Thu Sep 28 10:15:26 UTC 2000


You should already have the appropriate program on your system.  It's
called md5sum.  You just run it against whatever you download and
compare the string that it prints to stdout to the published string. 
Try running md5sum against any file on your system to see what comes
out.

For your own edification, type "man -k md5" and see what comes up on
your system.  After doing this, look at the man page for md5sum.  The
man page mentions that the complete documentation is contained in an
info file.  Type "info md5sum" to access this.  The command

rpm -qf `which md5sum`

shows that md5sum is part of the textutils package on my (Mandrake)
system, i.e. it's one of the GNU textutils.  This is also apparent from
the man and info pages.

The process of comparing strings will be less error prone if you use the
mouse to copy and paste the published string into a conditional such as

if [ published_string == `md5sum file | awk '{print $1}'` ]; then
    echo -e "\nThe strings are the same.\n"
else
    echo -e "\nThe strings are different.\n"
fi

Or better yet, write a short script that takes the published string and
the filename as arguments and performs this task.  Here's a hint:
Investigate the "read" command on the bash man page.

Examples from my system:

if [ 35303a9fce84148d6a0cbdc0bcce6b5e == `md5sum kdoc.pdf | awk '{print
$1}'` ]; then
    echo "The strings are the same."
else
    echo "The strings are different.";
fi

The strings are different.

if [ 45303a9fce84148d6a0cbdc0bcce6b5e == `md5sum kdoc.pdf | awk '{print
$1}'` ]; then
    echo "The strings are the same."
else
    echo "The strings are different.";
fi

The strings are the same.

Happy hacking,

Mark
-- 
---------------------------------------------------------------------------
Mark A. Martin					Dept of Applied Mathematics
http://www.amath.washington.edu/~mmartin	University of Washington
---------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: olug-unsubscribe at bstc.net
For additional commands, e-mail: olug-help at bstc.net



More information about the OLUG mailing list