Re: How do you use md5sum?

From: Barton L. Phillips (bartonphillips_at_sbcglobal.net)
Date: 04/30/05


Date: Sat, 30 Apr 2005 00:59:26 GMT

faeychild wrote:
> Unruh wrote:
>
>
>>Ohmster <notareal@emailaddress.com> writes:
>>
>>
>>>How do I check that these are indeed "official" FC3 image files and are
>>>the same as those offered by the linuxiso website? Running md5sum like
>>>this:
>>
>>>[ohmster@ohmster FC3]$ md5sum FC3-i386-disc1.iso
>>>db8c7254beeb4f6b891d1ed3f689b412 FC3-i386-disc1.iso
>>>[ohmster@ohmster FC3]$
>>
>>>Gives me this huge number that I could check against the md5sum number
>>>on the linuxiso website or ever on the alternate download site, but that
>>
>>Good. You have got it.
>>Now why would that leave lots of room for human error. Any change in the
>>files is likely to cause half of the bits in the md5sum to change. Ie,
>>each character remaining the same has about a 1/16 chance. 5 given
>
> His point is - comparing the output of md5sum with the actual checksum
> number, by eye, is error prone.
> There may be some way to pipe the output of md5sum through a compare
> function, but I don't know it. Surely a script wouldn't be too difficult
> to knock up.
> Then again, compairing checksums is not something I do too frequently.
>
Stupid script to do the job, it may not be the best perl but it works:

#! /usr/bin/perl -w

use strict;

# given an md5sum via stdin and an md5sum as arg 1 check them out

my $md5 = shift;

print "md5=$md5\n";

if($md5 =~ /^(.*) /) {
$md5 = $1;
}

my $test = <>;

my $md5part;

$test =~ /^(.*?) /;

$md5part = $1;

print "md5 from pipe=|$md5part|, md5 as argument=|$md5|\n";

if($md5part eq $md5) {
   print "md5 matches\n";
} else {
   print "md5 Does not Match!\n";
}