[][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!(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);

Re-exports

pub extern crate base64;

Functions

decode

Decode a Base64-URL string to data.

decode_and_push_to_vecDeprecated

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

decode_and_push_to_vec_mutDeprecated

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

decode_to_slice

Decode a Base64-URL string to data into a slice and return the slice with a valid length.

decode_to_vec

Decode a Base64-URL string to data and directly store into a mutable Vec<u8> reference by concatenating them and return the slice of the decoded data.

encode

Encode data to a Base64-URL string.

encode_and_push_to_stringDeprecated

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_push_to_string_mutDeprecated

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

encode_and_store_to_sliceDeprecated

Encode data to a Base64-URL string into a slice and return the valid length.

encode_to_slice

Encode data to a Base64-URL string to a slice and return the slice with a valid length.

encode_to_string

Encode data to a Base64-URL string and directly store to a mutable String reference by concatenating them and return the slice of the Base64-URL string. It is usually for generating a URL.

encode_to_vec

Encode data to Base64-URL data and directly store to a mutable Vec<u8> reference by concatenating them and return the slice of the Base64-URL data. It is usually for generating a URL.

escape

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.

escape_in_place

In-place 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.

escape_u8_slice

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

escape_u8_slice_in_place

In-place escape Base64 data to Base64-URL data. The conversion is not concerning with Base64 decoding. You need to make sure the input Base64 data is correct by yourself.

escape_vec_in_place

In-place escape Base64 data to Base64-URL data. The conversion is not concerning with Base64 decoding. You need to make sure the input Base64 data is correct by yourself.

unescape

Unescape a Base64-URL string to a Base64 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.

unescape_in_place

In-place unescape a Base64-URL string to a Base64 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.

unescape_u8_slice

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

unescape_u8_slice_try_in_place

Unescape Base64-URL data to Base64 data and try to do it in-place. It is unsafe because the conversion is not concerning with Base64 decoding. You need to make sure the input Base64-URL data is correct by yourself.

unescape_vec_in_place

In-place unescape Base64-URL data to Base64 data. It is unsafe because the conversion is not concerning with Base64 decoding. You need to make sure the input Base64-URL data is correct by yourself.

unsafe_escapeDeprecated

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_stringDeprecated

In-place 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_u8_sliceDeprecated

In-place escape Base64 data to Base64-URL data. It is unsafe because the conversion is not concerning with Base64 decoding. You need to make sure the input Base64 data is correct by yourself.

unsafe_escape_vecDeprecated

In-place escape Base64 data to Base64-URL data. It is unsafe because the conversion is not concerning with Base64 decoding. You need to make sure the input Base64 data is correct by yourself.

unsafe_unescapeDeprecated

Unescape a Base64-URL string to a Base64 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_stringDeprecated

In-place unescape a Base64-URL string to a Base64 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_u8_sliceDeprecated

Unescape Base64-URL data to Base64 data. It is unsafe because the conversion is not concerning with Base64 decoding. You need to make sure the input Base64-URL data is correct by yourself.

unsafe_unescape_vecDeprecated

In-place unescape Base64-URL data to Base64 data. It is unsafe because the conversion is not concerning with Base64 decoding. You need to make sure the input Base64-URL data is correct by yourself.