```{index} single: getstate; Digest::SHA function ``` ```{index} single: Digest::SHA::getstate; Perl function ``` # getstate Export a `Digest::SHA` object's state as a packed binary string. Returns the full hashing state — the intermediate hash values, buffered partial block, block counter, and message length counters — as a binary scalar. Pair with `_putstate` to restore the state later, for example when resuming a long hash across processes or persisting it to disk. Prefer the text-based `getstate` / `putstate` pair for human-readable output or for interchange across endianness. The binary form here is native-byte-order and tightly packed. ## Synopsis ```perl my $blob = $sha->_getstate; ``` ## What you get back A binary string of fixed length: 116 bytes for SHA-1/224/256, 212 bytes for SHA-384/512/512-224/512-256. ## Examples ```perl my $sha = Digest::SHA->new(256); $sha->add("hello "); my $snapshot = $sha->_getstate; my $other = Digest::SHA->new(256); $other->_putstate($snapshot); $other->add("world"); print $other->hexdigest; # same as full "hello world" hash ``` ```perl ## Persist a half-finished hash to disk: open my $fh, ">", "hash.state" or die $!; binmode $fh; print $fh $sha->_getstate; ``` ## Edge cases - The output is binary and includes null bytes; never interpret it as text. - Called on a non-`Digest::SHA` object, returns `undef`. ## Differences from upstream Fully compatible with upstream `Digest::SHA` {{ upstream.Digest_SHA }}. ## See also - `_putstate` — restore state produced by this method. - `getstate` — human-readable text variant. - `dump` / `load` — higher-level convenience wrappers around text state.