A basic base64 encoder / decoder for Rust.
Usage:
Import:
At the top of the file:
extern crate base64_lib;
Encode:
encode(&Vec) -> String
let input_vector: = String from.into_bytes;
let result_string: String = encode;
Decode:
decode(&String) -> Vec
let input_string: String = String from;
let result_vector: = decode;
Encode with custom alphabet:
encode_with_alphabet(&Vec, &String) -> Vec
let input_vector: = String from.into_bytes;
let alphabet: String = String from;
let result_string: String = encode_with_alphabet;
Decode with custom alphabet:
decode_with_alphabet(&String, &String) -> Vec
let input_string: String = String::from("SGVsbG8gV29ybGQ=");
let alphabet: String = String::from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
let result_vector: Vec<u8> = base64_lib::decode_with_alphabet(&input_string, &alphabet);
Notes:
- When using a custom alphabet, be sure there are 64 unique characters in the string.