Expand description
pw_base64
provides simple encoding of data into base64.
const INPUT: &'static [u8] = "I 💖 Pigweed".as_bytes();
// [`encoded_size`] can be used to calculate the size of the output buffer.
let mut output = [0u8; pw_base64::encoded_size(INPUT.len())];
// Data can be encoded to a `&mut [u8]`.
let output_size = pw_base64::encode(INPUT, &mut output).unwrap();
assert_eq!(&output[0..output_size], b"SSDwn5KWIFBpZ3dlZWQ=");
// The output buffer can also be automatically converted to a `&str`.
let output_str = pw_base64::encode_str(INPUT, &mut output).unwrap();
assert_eq!(output_str, "SSDwn5KWIFBpZ3dlZWQ=");
Functions§
- Encode
input
as base64 into theoutput_buffer
. - Encode
input
as base64 intooutput_buffer
and interprets it as a string. - Returns the size of the output buffer needed to encode an input buffer of size
input_size
.