Subject: | addfile and odd sizes outputs wrong digest |
Date: | Thu, 20 Jul 2006 16:04:22 +0200 |
To: | bug-SHA256 [...] rt.cpan.org |
From: | "Emmanuel Michon" <emmanuel.michon [...] polytechnique.org> |
Hello,
it seems sha256 will be wrong with addfile as soon as file is >8192 bytes.
Or is my (simple) code wrong?
Or maybe `perldoc Digest::SHA256' should be more clear about non
8192-multiple addfile behaviour.
Thanks for your help
#!/usr/bin/perl -w
use strict;
require 5.005;
use Digest::SHA256;
die "cannot be open\n" unless open F, "<$ARGV[0]";
my $context = Digest::SHA256::new(256);
$context->addfile(*F);
my $sha256 = $context->hexdigest();
$sha256 =~ s/ //g;
print "$sha256\n";
print `openssl dgst -sha256 \"$ARGV[0]\"`;
--
Très sincèrement,
e.m.