[][src]Crate base64_url

Base64 URL

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.

Re-exports

pub extern crate base64;

Functions

decode

Decode a Base64-URL string to data.

decode_and_push_to_vec

Decode a Base64-URL string to data and directly store into a Vec instance by concatenating them.

decode_and_store_to_slice

Decode a Base64-URL string to data into a slice.

encode

Encode data to a Base64-URL string.

encode_and_push_to_string

Encode data to a Base64-URL string and directly store into a String instance by concatenating them. It is usually for generating a URL.

encode_and_store_to_slice

Encode data to a Base64-URL string into a slice.

unsafe_escape

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.

unsafe_escape_owned[
Deprecated
]

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.

unsafe_unescape

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.

unsafe_unescape_owned[
Deprecated
]

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.