```{index} single: putstate; Digest::SHA function ``` ```{index} single: Digest::SHA::putstate; Perl function ``` # putstate Restore a `Digest::SHA` object's state from a packed binary string. The inverse of `_getstate`. Validates the length of the supplied blob against the receiver's algorithm and rewrites the internal hash state in place. After a successful `_putstate`, feeding more data with `add` continues the hash as if no break had occurred. The receiver's algorithm is **not** changed by this call; it must already match the algorithm the blob was produced under. ## Synopsis ```perl $sha->_putstate($blob); ``` ## What you get back The receiver on success, `undef` on failure (invalid length or bad object). ## Examples ```perl my $a = Digest::SHA->new(256); $a->add("first half"); my $blob = $a->_getstate; my $b = Digest::SHA->new(256); $b->_putstate($blob) or die "restore failed"; $b->add("second half"); print $b->hexdigest; ``` ```perl ## Round-trip through a file: open my $in, "<", "hash.state" or die $!; binmode $in; my $blob = do { local $/; <$in> }; my $sha = Digest::SHA->new(256); $sha->_putstate($blob); ``` ## Edge cases - Blob length must match the receiver's algorithm (116 vs 212 bytes); a mismatch returns `undef`. - Called on a non-`Digest::SHA` object, returns `undef`. ## Differences from upstream Fully compatible with upstream `Digest::SHA` {{ upstream.Digest_SHA }}. ## See also - `_getstate` — produces the blob consumed here. - `putstate` — text-based restore that also creates new objects. - `load` — text-based file-loading counterpart.