[][src]Crate lb64

Focuses on making a Base64 number as a type, with extensive documentation, and never panicing code

Base64 Library that has encoding and decoding of unsigned decimal values and bytes Along with a full fledged Base64 type in order to store the input of encoding an unsigned decimal value or bytes. Base64 type implements Clone, Eqs, Debug, along with multiple constructors for creation, all start with 'new', for example, from_string is from a Base64 compliant &str. Has default Configurations for Base64 numbers see more here for Standard, URL_SAFE with and without padding, IMAP and MIME compliant configs along with full fledged support of creating your own Base64 type. Furthermore, supports random generation of a n long Base64 number.

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 b64.decode_to_unsigned() {
        Ok(value) => v = value,
        Err(e) => println!("{}", e),
   let b64_other = Base64::new_encode_unsigned(&v, MIME);
   if b64_other == b64 {
        println!("They're equal!");
   match String::from_utf8(b64.decode_to_bytes()) {
        Ok(value) => println!("{}", value), // prints Hello
        Err(e) => println!("{}", e),

See Examples for more.



Creation of custom configs for Base64 numbers containing different characters, with or without padding, with or without a maximum line length. In addition, 5 configs are already defined because of their popularity (STANDARD, MIME, IMAP, URLSAFE with and without padding).


Enums for Errors that can occur when making a Config or when decoding



Base64 number