Expand description
§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!("");
}Macros§
- needed_
len - Returns the needed length for a buffer to (en/de)code up to
lenbytes. - round_
len - Rounds up
lento be an exact (en/de)coding buffer length.
Functions§
- decode
- Decodes as much from
inputas possible; returns a newly allocatedVec<u8>. - decode_
into - Decodes a base64-encoded string from
inputappending the result tooutputwhile there are valid characters; returns the number of decoded bytes. - encode
- Encode
inputto base64, returning a newly allocatedString. - encode_
into - Encode
inputto base64, appending the result tobuffer.