I'm trying to compare 2 MD5 hex digests but I can't seem to get it to work right. Here is the sub that is doing the checking ...
Code:
use Digest::MD5;
....
sub checkmd5($$) {
my ($package, $saidmd5) = @_;
open(FILE, $package)
or die "Can't open $package for reading";
binmode(FILE);
$pkgmd5 = Digest::MD5->new->addfile(*FILE)->hexdigest;
close(FILE);
if($pkgmd5 == $saidmd5) {
return 1;
} else { return 0; }
}
I've tested it by giving it a package with a MD5Sum of a4703d36ada98b2cf4f007831c345e71 and sending a82d3d36ada98b2cf4f007831c345e71 as the $saidmd5. Basically, they are being tested against eachother and should return 1 if they are the same and 0 if not. I currently get 1 when testing the two above. What did I do wrong?
Bookmarks