getstate_text#
Export a Digest::SHA object’s state as a human-readable text string.
Produces a multi-line plain-text dump of the current hashing state, including algorithm number, hash registers, pending block, and message length counters. The text form is portable across machines of different endianness and lends itself to inspection, diffing, and manual editing.
Pair with putstate to reconstruct the state later.
Synopsis#
my $text = $sha->getstate;
What you get back#
A newline-terminated ASCII string.
Examples#
my $sha = Digest::SHA->new(256);
$sha->add("hello");
print $sha->getstate;
## alg:256
## H:...
## block:...
## blockcnt:40
## lenhh:0 lenhl:0 lenlh:0 lenll:40
## Resume on another machine:
my $text = $sha->getstate;
...
my $resumed = Digest::SHA->putstate($text);
$resumed->add($more_data);
Edge cases#
The text format is stable across
Digest::SHAversions and endianness.Called on a non-
Digest::SHAobject, returnsundef.
Differences from upstream#
Fully compatible with upstream Digest::SHA 6.04.
See also#
putstate— inverse: parses text and constructs or updates an object.dump— write the text state to a file or STDOUT._getstate— binary counterpart for same-machine use.