putstate_text#
Construct or restore a Digest::SHA object from a text state string.
Accepts the text produced by getstate or dump and either:
As a class method (
Digest::SHA->putstate($text)), returns a new object with algorithm and state taken from the string.As an instance method (
$sha->putstate($text)), rewrites the receiver in place, switching algorithm if the string asks for a different one.
The algorithm is read from the text, so - unlike _putstate - you do not need to preconfigure the object with the correct algorithm.
Σύνοψη#
my $sha = Digest::SHA->putstate($text);
$sha->putstate($text);
Τι επιστρέφεται#
A Digest::SHA object on success, undef if the string could not be parsed.
Παραδείγματα#
my $text = $other->getstate;
my $sha = Digest::SHA->putstate($text);
$sha->add($remaining_data);
## Update an existing object from a state string:
my $sha = Digest::SHA->new(256);
$sha->putstate($text);
## Invalid input returns undef:
my $sha = Digest::SHA->putstate("garbage");
print defined $sha ? "ok" : "undef"; # undef
Οριακές περιπτώσεις#
Unrecognised or truncated text returns
undefrather than croaking.When used as an instance method, the receiver’s algorithm is overwritten by whatever the text specifies.
Διαφορές από το upstream#
Fully compatible with upstream Digest::SHA 6.04.
Δείτε επίσης#
getstate- produces the strings this method consumes.load- convenience wrapper that reads the text from a file._putstate- binary-state counterpart for same-machine use.