#base64-encode #utf-8 #base64 #url #decode

no-std base64-url

Base64 encode, decode, escape and unescape for URL applications

35 stable releases

3.0.3 Mar 16, 2026
3.0.2 Oct 28, 2025
3.0.0 May 1, 2024
2.0.2 Dec 24, 2023
1.1.7 Nov 16, 2018

#229 in Encoding

Download history 19766/week @ 2025-12-26 61533/week @ 2026-01-02 97421/week @ 2026-01-09 86759/week @ 2026-01-16 94019/week @ 2026-01-23 96768/week @ 2026-01-30 113553/week @ 2026-02-06 81562/week @ 2026-02-13 99007/week @ 2026-02-20 121103/week @ 2026-02-27 133704/week @ 2026-03-06 128761/week @ 2026-03-13 130803/week @ 2026-03-20 121916/week @ 2026-03-27 137532/week @ 2026-04-03 103855/week @ 2026-04-10

518,545 downloads per month
Used in 157 crates (54 directly)

MIT license

22KB
352 lines

Base64 URL

CI

Base64 encode, decode, escape and unescape for URL applications.

Examples

Encode data to a Base64-URL string.

assert_eq!("SGVsbG8sIHdvcmxkIQ", base64_url::encode("Hello, world!"));

Decode a Base64-URL string to data.

assert_eq!(b"Hello, world!", base64_url::decode("SGVsbG8sIHdvcmxkIQ").unwrap().as_slice());

Escape a Base64 string to a Base64-URL string. The conversion is not concerning with Base64 decoding. You need to make sure the input string is a correct Base64 string by yourself.

assert_eq!("SGVsbG8sIHdvcmxkIQ", base64_url::escape("SGVsbG8sIHdvcmxkIQ=="));

Unescape a Base64-URL string to a Base64-URL string. The conversion is not concerning with Base64 decoding. You need to make sure the input string is a correct Base64-URL string by yourself.

assert_eq!("SGVsbG8sIHdvcmxkIQ==", base64_url::unescape("SGVsbG8sIHdvcmxkIQ"));

Besides, you can also use other encode_*, decode_*, escape_*, unescape_* associated functions to deal with more specific cases. For example,

let hash = &[1, 2, 3, 4, 5, 6, 7, 8, 9];
let mut url = String::from("https://example.com/?hash=");

assert_eq!("AQIDBAUGBwgJ", base64_url::encode_to_string(hash, &mut url));
assert_eq!("https://example.com/?hash=AQIDBAUGBwgJ", url);

Std

Enable the std features to compile this crate with std.

[dependencies.base64-url]
version = "*"
features = ["std"]

Crates.io

https://crates.io/crates/base64-url

Documentation

https://docs.rs/base64-url

License

MIT

Dependencies

~210KB