Subject: | Subsequent calls to retrieve digest return different digest |
Subsequent calls to retrieve the digest from a digest object return a value different to the initial value returned.
The value returned seems to be the digest of an empty string. It doesn't seem to matter which digest is used.
I found the issue while where I was using b64digests, and wanted to check what result I was getting against the system sha512sum, which outputs hex. So I output a hexdigest for comparison, after the b64digest call, and discovered it didn't match!
What I think should happen is that repeated calls to the digest methods should either return the same value, or the subsequent calls should die as the object no longer represents the data that it is supposed to be a digest of.
Sample code.
use v5.18;
use strict;
use warnings;
use autodie;
use Digest::SHA;
while (@ARGV) {
my $file_name = shift;
my $sha = Digest::SHA->new(512);
$sha->addfile($file_name);
say $file_name;
# To my mind, these should all output the same value.
say $sha->hexdigest;
say $sha->hexdigest;
say $sha->hexdigest;
}