lb64

Crates.iolb64
lib.rslb64
version0.1.2
sourcesrc
created_at2018-11-24 08:51:29.504897
updated_at2018-11-25 07:11:38.043591
descriptionBase64 Library with a fully configurable Base64 type
homepage
repositoryhttps://github.com/NickHackman/lb64
max_upload_size
id98394
size114,894
Nick Hackman (NickHackman)

documentation

README

lb64

Crate API


A Rust library for Base64 encoding and decoding unsigned integers and bytes.

lb64 strives to be panic and unsafe free with minimal dependencies and excellent documentation.

lb64 provides the ability to both utilize common Base64 configurations, such as IMAP, STANDARD, MIME, and Base64url and also provides the utilities to create your own Base64 configuration. It also creates a full fledged Base64 type and creation of a random Base64 number of n length.

See more information on Wikipedia

Note: this crate is Nightly only. Due to the current use of overflowing_pow for unsigned integer decoding

Why

This library is a fairly simple implementation in order to properly learn how to write code and documentation in Rust and is my first project in Rust. Pull requests are welcome and appreciated for learning purposes.

Usage

Add this to your Cargo.toml:

[dependencies]
lb64 = "0.1.2"

Add this to your src/main.rs or src/lib.rs:

extern crate lb64;

Example

extern crate lb64;

use lb64::Base64;
use lb64::config::{Config, MIME};

fn main() {
    let s: &str = "Hello!";
    let b64 = Base64::new_encode_bytes(s.as_bytes(), MIME);
    println!("{}", b64);
    let mut v: u128 = 0;
    match lb64.decode_to_unsigned() {
         Ok(value) => v = value,
         Err(e) => println!("{}", e),
    }
    let lb64_other = Base64::new_encode_unsigned(&v, MIME);
    if lb64_other == b64 {
         println!("They're equal!");
    }
    match String::from_utf8(lb64.decode_to_bytes()) {
         Ok(value) => println!("{}", value), // prints Hello
         Err(e) => println!("{}", e),
    }
 }

Documentation

License

lb64 is distributed under the GNU General Public License Version 3

Commit count: 7

cargo fmt