Skip to main content

encode

Function encode 

Source
pub fn encode(bytes: &[u8]) -> String
Expand description

Encodes bytes using RFC 4648 base64url (alphabet A–Za–z0–9-_), without padding.

The output uses - and _ instead of + and /, making it safe for use in URLs, HTTP headers, and cookie values without percent-encoding. Returns an empty string when bytes is empty.

§Examples

use modo::encoding::base64url;

assert_eq!(base64url::encode(b"Hello"), "SGVsbG8");
assert_eq!(base64url::encode(b""), "");