Instead of handing a file handle to $ctx, you would instead read 64K of data from the file handle, and give that chunk of data to $ctx. So it should be something like:
sub md5sum{ my $file = shift; my $digest = ""; eval{ open(FILE, $file) or die "Can't find file $file\n"; my $data; read FILE, $data, 65536 or die "Can't read from $file\n$!"; my $ctx = Digest::MD4->new; $ctx->add($data); $digest = $ctx->hexdigest; close(FILE); }; if($@){ print $@; return ""; } return $digest; }
Note: The code is untested...
...roboticusIn reply to Re^5: MD5 Hash
by roboticus
in thread MD5 Hash
by Karger78
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |