9 releases

Uses old Rust 2015

0.2.2 Apr 29, 2018
0.2.1 Sep 25, 2017
0.1.6 Sep 24, 2017

#1832 in Encoding

MIT license

25KB
445 lines

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.

No runtime deps