Sub checkmd5 ()
{
My ($ md5val, $ scan_file) = @_;
If ($ md5val !~ /[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 ";
Print "check file:/t". $ scan_file. "/N ";
Print "has known MD5:/t". $ md5val. "/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 will be 32 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 ($ md5val = ~ /^ $ Retdgt $/I) {print "[success] match MD5./n"; return 1 ;}
Else {print "[Error] dismatch MD5 value./N"; return 0 ;}
}
In addition,
If the file is too large, the md5_hex () method may cause an out of memory problem.