Base64 Stream

Build Status Build status

To encode/decode large data with the standard Base64 encoding.

Examples

Encode

ToBase64Reader

```rust extern crate base64_stream;

use std::io::Cursor;

use std::io::Read;

use base64_stream::ToBase64Reader;

let testdata = b"Hi there, this is a simple sentence used for testing this crate. I hope all cases are correct.".tovec();

let mut reader = ToBase64Reader::new(Cursor::new(test_data));

let mut base64 = [0u8; 4096];

let c = reader.read(&mut base64).unwrap();

asserteq!(b"SGkgdGhlcmUsIHRoaXMgaXMgYSBzaW1wbGUgc2VudGVuY2UgdXNlZCBmb3IgdGVzdGluZyB0aGlzIGNyYXRlLiBJIGhvcGUgYWxsIGNhc2VzIGFyZSBjb3JyZWN0Lg==".tovec(), base64[..c].to_vec()); ```

Decode

FromBase64Reader

```rust extern crate base64_stream;

use std::io::Cursor;

use std::io::Read;

use base64_stream::FromBase64Reader;

let base64 = b"SGkgdGhlcmUsIHRoaXMgaXMgYSBzaW1wbGUgc2VudGVuY2UgdXNlZCBmb3IgdGVzdGluZyB0aGlzIGNyYXRlLiBJIGhvcGUgYWxsIGNhc2VzIGFyZSBjb3JyZWN0Lg==".to_vec();

let mut reader = FromBase64Reader::new(Cursor::new(base64));

let mut test_data = [0u8; 4096];

let c = reader.read(&mut test_data).unwrap();

asserteq!(b"Hi there, this is a simple sentence used for testing this crate. I hope all cases are correct.".tovec(), testdata[..c].tovec()); ```

Todo

  1. Encode
    1. ToBase64Writer
  2. Decode
    1. FromBase64Writer

Crates.io

https://crates.io/crates/base64-stream

Documentation

https://docs.rs/base64-stream

License

MIT