#decode #base64 #encode #utf8 #url

no-std base64-url

Base64 encode, decode, escape and unescape for URL applications

27 stable releases

1.4.10 Apr 21, 2021
1.4.9 Mar 10, 2021
1.4.8 Nov 13, 2020
1.4.7 Jul 29, 2020
1.1.7 Nov 16, 2018

#167 in Encoding

Download history 4429/week @ 2021-04-08 3868/week @ 2021-04-15 4403/week @ 2021-04-22 4952/week @ 2021-04-29 3713/week @ 2021-05-06 3751/week @ 2021-05-13 3591/week @ 2021-05-20 3044/week @ 2021-05-27 3696/week @ 2021-06-03 3839/week @ 2021-06-10 4012/week @ 2021-06-17 3820/week @ 2021-06-24 3329/week @ 2021-07-01 4275/week @ 2021-07-08 3644/week @ 2021-07-15 3467/week @ 2021-07-22

15,367 downloads per month
Used in 38 crates (5 directly)

MIT license

22KB
377 lines

Base64 URL

CI

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

Examples

Encode data to a Base64-URL string.

extern crate base64_url;

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

Decode a Base64-URL string to data.

extern crate base64_url;

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.

extern crate base64_url;

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.

extern crate base64_url;

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,

extern crate base64_url;

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);

Crates.io

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

Documentation

https://docs.rs/base64-url

License

MIT

Dependencies

~200KB