Sub CheckMD5 ()
{
My ($md 5val, $scan _file) = @_;
if ($md 5val!~/[0-9a-f]{32}/i) {die "invalid MD5 value./n";}
if (!-e $scan _file) {print "No Updatex file exist. /n "; return-1;}
Print "/n<<<<<<<<<<<<<<<<<<<<<< Checking MD5 >>>>>>>>>>>>>>>>>/n/n ";
Print "Check File:/t". $scan _file. " /n ";
Print "has known MD5:/t". $md 5val. " /n ";
Open (FILE, $scan _file) or die "Can ' t open ' $scan _file ': $!";
Binmode (FILE);
My $retdgt = Digest::md5->new->addfile (*file)->hexdigest; #The returned string would be a bytes long.
Close FILE;
if ($retdgt!~/[0-9a-f]{32}/i) {die ' Invalid MD5 value from digest::md5./n ';}
Print "Get MD5 as:/t $retdgt/n";
if ($md 5val =~/^ $retdgt $/i) {print "[Success] Match MD5./n/n"; return 1;}
else{print "[Error] dismatch MD5 value./n"; return 0;}
}
Other than that
If the file is too large, use the Md5_hex () method, there will be an out of memory issue