```{index} single: encode_base64url; MIME::Base64 function ``` ```{index} single: MIME::Base64::encode_base64url; Perl function ``` # encode_base64url Encode bytes using the URL- and filename-safe base64 alphabet, with no padding and no line breaks. ## Synopsis ```perl use MIME::Base64 qw(encode_base64url); my $token = encode_base64url($bytes); ``` ## What you get back A single unbroken ASCII string using the alphabet `[A-Za-z0-9-_]`. Trailing `=` padding is stripped. The result is safe to drop into URLs, path segments, cookie values, and JWT components without percent-escaping. The output is always one line — never wrapped. ## Examples ```perl encode_base64url("Aladdin:open sesame"); ## "QWxhZGRpbjpvcGVuIHNlc2FtZQ" encode_base64url("\xFB\xFF"); ## "-_8" (note the '-' and '_' where '+' and '/' would appear) encode_base64url(""); ## "" ``` ## Edge cases - Empty input returns the empty string. - Bytes that would encode to `+` under standard base64 become `-`; bytes that would encode to `/` become `_`. - No `=` appears in the output under any input length. ## Differences from upstream Fully compatible with upstream `MIME::Base64` {{ upstream.MIME_Base64 }}. ## See also - `decode_base64url` — the inverse operation. - `encode_base64` — standard variant with wrapping and padding.