base64-lib 0.2.2

A base64 encoder / decoder
Documentation

A basic base64 encoder / decoder for Rust.

STATUS:

  • master: pipeline status
  • develop: pipeline status

==========================================

  1. Usage
  2. Notes
  3. License

Usage:

Import:

At the top of the file:

extern crate base64_lib;

Encode:

encode(&Vec) -> String

let input_vector: Vec<u8> = String::from("Hello World").into_bytes();
let result_string: String = base64_lib::encode(&input_vector);

Decode:

decode(&String) -> Vec

let input_string: String = String::from("SGVsbG8gV29ybGQ=");
let result_vector: Vec<u8> = base64_lib::decode(&input_string);

Encode with custom alphabet:

encode_with_alphabet(&Vec, &String) -> Vec

let input_vector: Vec<u8> = String::from("Hello World").into_bytes();
let alphabet: String = String::from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
let result_string: String = base64_lib::encode_with_alphabet(&input_vector, &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.

License:

Licensed under the MIT License.