Skip Menu |

This queue is for tickets about the Digest-SHA CPAN distribution.

Report information
The Basics
Id: 122117
Status: rejected
Worked: 5 min
Priority: 0/
Queue: Digest-SHA

People
Owner: Nobody in particular
Requestors: SPINER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 5.95
Fixed in: (no value)



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; }
Please refer to the Digest::SHA documentation (under OOP style): digest, hexdigest, and b64digest are read-once operations: they reset the SHA state after being called. Use the 'clone' method if you want to preserve the original state. This behavior is required of all Digest modules, not just Digest::SHA. Mark