```{index} single: md5_b64; Digest::MD5 function ``` ```{index} single: Digest::MD5::md5_b64; Perl function ``` # md5_b64 One-shot MD5 digest, returned as a 22-character base64 string. ## Synopsis ```perl use Digest::MD5 qw(md5_base64); my $b64 = md5_base64($data); # 22 chars, no padding ``` ## What you get back A 22-character string from the standard base64 alphabet `A-Z a-z 0-9 + /`. The tail is **not** padded to a multiple of 4 — the redundancy would encode nothing — so if an interop partner demands strict base64, append `"=="` yourself. Base64 is about 30% shorter than hex and still fits on one line in a log or URL query parameter. The price is that it contains `/` and `+`, which are not safe in URL paths without further escaping. ## Examples Compact digest for a cache key or tag: ```perl use Digest::MD5 qw(md5_base64); my $tag = md5_base64($payload); ## 22-character identifier, e.g. "rL0Y20zC+Fzt72VPzMSk2A" ``` Pad for strict base64 parsers: ```perl my $padded = md5_base64($payload) . "=="; ``` Store alongside the content in a manifest: ```perl printf "%s %s\n", md5_base64($bytes), $name; ``` ## Edge cases - `md5_base64()` with no arguments returns `1B2M2Y8AsgTpgAmY7PhCfg`. - Wide-character arguments croak; encode first. - The `+` and `/` characters require percent-encoding if the result appears in a URL path. Consider a URL-safe base64 transform (`tr|+/|-_|`) when serving digests in URLs. ## Differences from upstream Fully compatible with upstream `Digest::MD5` {{ upstream.Digest_MD5 }}. ## See also - `md5` — raw-byte form - `md5_hex` — hex form (longer, URL-safer) - `b64digest` — OO form over a reusable context - `add` — feed data incrementally for larger inputs