in reply to Re: MD5 Hash
in thread MD5 Hash

That sounds like a good idea. first i will past the code i have to make sure it's not a code flaw. What do you think?
sub md5sum{ my $file = shift; my $digest = ""; eval{ open(FILE, $file) or die "Can't find file $file\n"; my $ctx = Digest::MD4->new; $ctx->addfile(*FILE); $digest = $ctx->hexdigest; close(FILE); }; if($@){ print $@; return ""; } return $digest; }

Replies are listed 'Best First'.
Re^3: MD5 Hash
by GrandFather (Saint) on Dec 01, 2009 at 22:20 UTC
    use strict; use warnings; sub md4sum { my $fileName = shift; my $digest = ""; eval { open my $file, '<', $fileName or die "Can't open $fileName: $! +\n"; my $buffer; read $file, $buffer, 2**16; close ($file); my $ctx = Digest::MD4->new; $ctx->add ($buffer); $digest = $ctx->hexdigest; }; if ($@) { print $@; return ""; } return $digest; }

    Update s/2\^16/2**16/. Thanks AnomalousMonk


    True laziness is hard work
Re^3: MD5 Hash
by Karger78 (Beadle) on Dec 02, 2009 at 14:44 UTC
    Thanks that worked perfectly. Thanks for the suggestions everyone.