```{index} single: hexdigest; Digest::MD5 function ``` ```{index} single: Digest::MD5::hexdigest; Perl function ``` # hexdigest Finalise the context and return the digest as 32 lowercase hex chars. ## Synopsis ```perl my $hex = $ctx->hexdigest; # 32 chars, [0-9a-f] ``` ## What you get back A 32-character ASCII string containing only `0-9` and `a-f`. This is the form you want for ETags, `md5sum`-style checksum files, log output, and anywhere humans will read the digest. No `0x` prefix, no separators, lowercase. **`hexdigest` is destructive**: the context is reset to empty after the digest is produced. Clone first if you need to keep going. ## Examples Common one-liner: ```perl my $hex = Digest::MD5->new->add("hello")->hexdigest; ## 5d41402abc4b2a76b9719d911017c592 ``` Digest the same context twice by cloning: ```perl $ctx->add("stream so far"); my $checkpoint = $ctx->clone->hexdigest; $ctx->add("more data"); my $final = $ctx->hexdigest; ``` Build an `md5sum`-compatible line: ```perl open(my $fh, '<:raw', $path) or die $!; printf "%s %s\n", Digest::MD5->new->addfile($fh)->hexdigest, $path; ``` ## Edge cases - Empty context → `d41d8cd98f00b204e9800998ecf8427e` (the MD5 of the empty string). - The result is always lowercase; if an external format demands uppercase, call `uc` on it. - Resets the context, so `$ctx->hexdigest` twice without intervening `add` calls gives the empty-string digest the second time. ## Differences from upstream Fully compatible with upstream `Digest::MD5` {{ upstream.Digest_MD5 }}. ## See also - `digest` — same content as 16 raw bytes - `b64digest` — shorter base64 encoding of the same digest - `md5_hex` — one-shot functional form - `clone` — preserve the context before finalising