Crates.io | lb64 |
lib.rs | lb64 |
version | 0.1.2 |
source | src |
created_at | 2018-11-24 08:51:29.504897 |
updated_at | 2018-11-25 07:11:38.043591 |
description | Base64 Library with a fully configurable Base64 type |
homepage | |
repository | https://github.com/NickHackman/lb64 |
max_upload_size | |
id | 98394 |
size | 114,894 |
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
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.
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;
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),
}
}
lb64 is distributed under the GNU General Public License Version 3