tree: 4cb738a3af754ac2e44a31850478976057b5c3d1 [path history] [tgz]
  1. .cargo-checksum.json
  2. Cargo.toml
  7. benches/
  8. examples/
  9. src/
  10. tests/



It's base64. What more could anyone want?


In Cargo.toml: base64 = "~0.6.0"

extern crate base64;

use base64::{encode, decode};

fn main() {
    let a = b"hello world";
    let b = "aGVsbG8gd29ybGQ=";

    assert_eq!(encode(a), b);

See the docs for all the details.


I have a fondness for small dependency footprints, ecosystems where you can pick and choose what functionality you need, and no more. Unix philosophy sort of thing I guess, many tiny utilities interoperating across a common interface. One time making a Twitter bot, I ran into the need to correctly pluralize arbitrary words. I found on npm a module that did nothing but pluralize words. Nothing else, just a couple of functions. I'd like for this to be that “just a couple of functions.”



rustup run nightly cargo bench







Then analyze the results, again with perf:

sudo perf annotate -l

    2.82 :        1069b:       shr    $0x38,%rax
         :                  if morsel == decode_tables::INVALID_VALUE {
         :                      bad_byte_index = input_index;
         :                      break;
         :                  };
         :              // fast loop of 8 bytes at a time
         :              while input_index < length_of_full_chunks {
         :                  let mut accum: u64;
         :                  if morsel == decode_tables::INVALID_VALUE {



cargo +nightly fuzz run roundtrip
cargo +nightly fuzz run roundtrip_no_pad
cargo +nightly fuzz run roundtrip_mime -- -max_len=10240
cargo +nightly fuzz run roundtrip_random_config -- -max_len=10240


This project is dual-licensed under MIT and Apache 2.0.