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.

תקציר#

my $text = $sha->getstate;

מה מוחזר#

A newline-terminated ASCII string.

דוגמאות#

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);

מקרי קצה#

  • The text format is stable across Digest::SHA versions and endianness.

  • Called on a non-Digest::SHA object, returns undef.

הבדלים מן ה-upstream#

Fully compatible with upstream Digest::SHA 6.04.

ראו גם#

  • 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.