digest#
Finalise the context and return the 16-byte raw binary digest.
Σύνοψη#
my $bin = $ctx->digest; # exactly 16 bytes
Τι επιστρέφεται#
A 16-byte Perl string holding the raw digest. This is the most compact representation - handy for binary protocols or packing into fixed-width records - but it typically contains non-printable bytes, so do not paste it into log lines without encoding.
digest is destructive. After it returns, the context is automatically reset to the empty state and is immediately ready to digest a new message. To read the digest without destroying the state, use $ctx->clone->digest instead.
Παραδείγματα#
Raw bytes, then convert to hex by hand:
my $bin = Digest::MD5->new->add("abc")->digest;
printf "%v02x\n", $bin; # 90.01.50.98.3c.d2.4f.b0.d6.96.3f.7d.28.e1.7f.72
Pack into a fixed-width binary record:
my $record = pack("A16 a16", $filename, $ctx->digest);
Peek at an intermediate digest without resetting:
my $snapshot = $ctx->clone->digest; # $ctx keeps going
$ctx->add($more);
Οριακές περιπτώσεις#
Called on a context with no data added, returns the MD5 of the empty string (
d41d8cd98f00b204e9800998ecf8427eas hex).Resets before returning, so calling
digesttwice in a row without adding data between the calls gives the empty-string digest the second time.
Διαφορές από το upstream#
Fully compatible with upstream Digest::MD5 2.58.
Δείτε επίσης#
hexdigest- same digest, formatted as 32 hex charactersb64digest- same digest, base64-encodedmd5- one-shot functional formclone- take a snapshot digest without resetting the context