#base64 #io #self

basic64

A straightforward implementation of base64

7 releases

Uses new Rust 2024

new 0.3.1 Oct 16, 2025
0.3.0 Oct 4, 2025
0.2.2 Oct 4, 2025
0.2.1 Sep 26, 2025
0.1.1 Sep 25, 2025

#2143 in Encoding

Download history 51/week @ 2025-09-17 292/week @ 2025-09-24 212/week @ 2025-10-01 35/week @ 2025-10-08

590 downloads per month

MIT license

8KB
145 lines

basic64

A straightforward implementation of base64 in Rust.


lib.rs:

Usage

use std::io::{self, Read};

use basic64;

fn main() {
    let mut handle = io::stdin().lock();

    let mut input = [0u8; basic64::round_len!(dec 8_192)];
    // !
    let mut encoded = String::with_capacity(basic64::needed_len!(enc input.len()));

    while let Ok(n) = handle.read(&mut input) {
        if n == 0 {
            break;
        }

        // !
        basic64::encode_into(&input[..n], &mut encoded);
        print!("{}", encoded);
        encoded.clear();
    }

    println!("");
}

No runtime deps