in reply to Re^2: MD5 Hash
in thread MD5 Hash

Karger78:

Perhaps you can SSH into the system hosting the network share, and have that computer compute the md5? If you're managing a network with multiple network shares, you might get a good speed boost by making each host compute the md5 values for the files it serves.

...roboticus

Replies are listed 'Best First'.
Re^4: MD5 Hash
by Karger78 (Beadle) on Dec 01, 2009 at 20:57 UTC
    I like the idea of checking the 1st 64k of the md5 hash. How would i accomplish that from the code i posted above.
      Karger78:

      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...

      ...roboticus