```{index} single: digest; Digest::MD5 function ``` ```{index} single: Digest::MD5::digest; Perl function ``` # digest Finalise the context and return the 16-byte raw binary digest. ## Synopsis ```perl my $bin = $ctx->digest; # exactly 16 bytes ``` ## What you get back 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. ## Examples Raw bytes, then convert to hex by hand: ```perl 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: ```perl my $record = pack("A16 a16", $filename, $ctx->digest); ``` Peek at an intermediate digest without resetting: ```perl my $snapshot = $ctx->clone->digest; # $ctx keeps going $ctx->add($more); ``` ## Edge cases - Called on a context with no data added, returns the MD5 of the empty string (`d41d8cd98f00b204e9800998ecf8427e` as hex). - Resets *before* returning, so calling `digest` twice in a row without adding data between the calls gives the empty-string digest the second time. ## Differences from upstream Fully compatible with upstream `Digest::MD5` {{ upstream.Digest_MD5 }}. ## See also - `hexdigest` — same digest, formatted as 32 hex characters - `b64digest` — same digest, base64-encoded - `md5` — one-shot functional form - `clone` — take a snapshot digest without resetting the context