#decode #base64 #encode #utf8 #url

base64-url

Base64 encode, decode, escape and unescape for URL applications

16 stable releases

✓ Uses Rust 2018 edition

1.1.13 Feb 21, 2020
1.1.12 Sep 16, 2019
1.1.8 Jul 28, 2019
1.1.7 Nov 16, 2018
1.1.4 Aug 26, 2018

#212 in Encoding

Download history 191/week @ 2019-12-10 13/week @ 2019-12-17 19/week @ 2019-12-24 5/week @ 2019-12-31 64/week @ 2020-01-07 93/week @ 2020-01-14 25/week @ 2020-01-21 22/week @ 2020-01-28 7/week @ 2020-02-04 25/week @ 2020-02-11 103/week @ 2020-02-18 100/week @ 2020-02-25 46/week @ 2020-03-03 27/week @ 2020-03-10 94/week @ 2020-03-17 52/week @ 2020-03-24

200 downloads per month
Used in 10 crates (via short-crypt)

MIT license

9KB
117 lines

Base64 URL

Build Status

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!("Hello, world!".as_bytes().to_vec(), base64_url::decode("SGVsbG8sIHdvcmxkIQ").unwrap());

Escape a Base64 string to a Base64-URL string. It is unsafe because 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::unsafe_escape("SGVsbG8sIHdvcmxkIQ=="));

Unescape a Base64-URL string to a Base64-URL string. It is unsafe because 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::unsafe_unescape("SGVsbG8sIHdvcmxkIQ"));

Besides, in order to reduce the copy times of strings, you can also use encode_and_push_to_string, decode_and_push_to_vec, unsafe_escape_owned and unsafe_unescape_owned associated functions to use the same memory space.

Crates.io

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

Documentation

https://docs.rs/base64-url

License

MIT

Dependencies

~175KB