On Sat, Jul 21, 2001 at 03:48:44PM -0400, Tim Howe wrote:
> I ran a checksum on the iso I have and it
> was completely different!
^^^^^^^^^^
funk:~/tmp% echo 1 > test1
funk:~/tmp% echo 2 > test2
funk:~/tmp% md5 test1
MD5 (test1) = b026324c6904b2a9cb4b88d6d61c81d1
funk:~/tmp% md5 test2
MD5 (test2) = 26ab0db90d72e28ad0ba1e22ee510510
Only one overlapping character (the 2 near the middle) out of 32.
> I think the download was corrupted or
> something. DO NOT TRUST IE TO DOWNLOAD!
Pull that dunce cap down tight, Tim!
This is a subroutine (modified to be standalone) from a package fetching
script I wrote. Since it is theoretically possible (has anyone done it yet?)
to modify a file and "pad" it in such a way that it produces the same md5
checksum as another file (which was thought to be impossible), it's a good
idea to check the file's size also.
Save it as something like 'md5check', and use it like so -
% md5check <file> <size> <md5 checksum>
where <size> and <checksum> are what they should be.
----------------------------------------------------------
#!/usr/bin/perl -w
use strict;
my ($file, $check_size, $check_md5) = @ARGV;
if (! (-f "$file")) {
die "Could not check_size_n_md5 $file because $file does not exist!\n";
}
my $size = (stat ($file))[7];
my $md5 = `md5 $file`;
chomp $md5;
$md5 =~ s/MD5 \($file\) = //;
if ($check_size ne $size) {
print "$file is the wrong size!\n";
exit (1);
} elsif ($check_md5 ne $md5) {
print "$file has the wrong md5 checksum!\n";
exit (2);
} else {
print "$file checks out OK :)\n";
exit (0);
}
______________________________________________________________
Written for OpenBSD, YMMV.
<[EMAIL PROTECTED]>