L
Lee Hibberd
Hello all
I have used sha1_file in php and want to know if there is an
equivalent in perl. i.e. I want to produce a sha1 value based on the
composition of the file and not the filename. I have used the perl
sha1 digest, but I'm unsure if this is working correctly. One reason
for my uncertainty is that the sha1 values produced by php sha1_file
differ. The second reason is I guess I would need to feed the
bit-stream through the sha1 in perl as if it were a line of text, and
I'm not sure that my code does that:
my $fn="$file";
my $fh = new IO::File;
$fh->open($fn) or @row = $dbh->do( "
UPDATE All_Locations SET SHA1Date = Date(),SHA1Time =
Time(),ErrorCode=\'NoFile\' WHERE FileID=$row[0]
" );
$digest = new Digest::SHA1;
$digest->addfile($fh);
$fh->close;
$sha1var = $digest->hexdigest;
print $file.": ".$sha1var."\n";
Any help would be greatly appreciated.
Lee Hibberd
National Library of Scotland
I have used sha1_file in php and want to know if there is an
equivalent in perl. i.e. I want to produce a sha1 value based on the
composition of the file and not the filename. I have used the perl
sha1 digest, but I'm unsure if this is working correctly. One reason
for my uncertainty is that the sha1 values produced by php sha1_file
differ. The second reason is I guess I would need to feed the
bit-stream through the sha1 in perl as if it were a line of text, and
I'm not sure that my code does that:
my $fn="$file";
my $fh = new IO::File;
$fh->open($fn) or @row = $dbh->do( "
UPDATE All_Locations SET SHA1Date = Date(),SHA1Time =
Time(),ErrorCode=\'NoFile\' WHERE FileID=$row[0]
" );
$digest = new Digest::SHA1;
$digest->addfile($fh);
$fh->close;
$sha1var = $digest->hexdigest;
print $file.": ".$sha1var."\n";
Any help would be greatly appreciated.
Lee Hibberd
National Library of Scotland