2ge has asked for the wisdom of the Perl Monks concerning the following question:
Please, help me, so I will get the same hash using perl. Thank you monkers!#!/usr/bin/perl -w use strict; die "need file as parameter" unless my $file = $ARGV[0]; open(my $fh, $file) or die "Can't open file $file: $!"; die "File $file is too small!" if -s $file < 65536; my $hashstring = -s $file; #calculate first 64kb for(1 .. 65536/8) { read($fh, my $byte, 4); my $ll = unpack("LL", $byte); #here is missing code } #calculate last 64kb seek $fh, -65536, 2; for(1 .. 65536/8) { read($fh, my $byte, 4); my $ll = unpack("LL", $byte); #here is missing code } close($fh); printf("Hash of $file is: %016x", $hashstring);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating custom hash of file
by grinder (Bishop) on Mar 18, 2007 at 11:22 UTC | |
by bart (Canon) on Mar 18, 2007 at 15:06 UTC | |
by Anno (Deacon) on Mar 18, 2007 at 19:47 UTC | |
by 2ge (Scribe) on Mar 18, 2007 at 11:55 UTC | |
by grinder (Bishop) on Mar 18, 2007 at 12:08 UTC | |
by 2ge (Scribe) on Mar 18, 2007 at 12:13 UTC | |
by graff (Chancellor) on Mar 18, 2007 at 14:34 UTC | |
by 2ge (Scribe) on Mar 18, 2007 at 21:59 UTC | |
|
Re: Creating custom hash of file
by GrandFather (Saint) on Mar 18, 2007 at 10:52 UTC | |
by 2ge (Scribe) on Mar 18, 2007 at 11:10 UTC | |
|
Re: Creating custom hash of file
by 2ge (Scribe) on Jan 01, 2008 at 19:43 UTC |