Skip to main content

base64_encode

Function base64_encode 

Source
pub fn base64_encode(data: &[u8], out: &mut [u8]) -> Result<()>
Expand description

Encodes data into out (RFC 4648 §4).

out must hold at least encoded_len(data.len()) bytes; exactly that many are written.

use pith_digest::base64::{base64_encode, encoded_len};
let mut out = [0u8; encoded_len(6)];
base64_encode(b"foobar", &mut out).unwrap();
assert_eq!(&out, b"Zm9vYmFy");

§Errors

crate::Error::TooLarge if out is shorter than the encoding needs.