pub fn encode(b: &[u8], w: &mut dyn Write) -> Result
Expand description
Base64 encode the provided bytes.
Splits the provided b
into 57 bytes chunks and
base64 encodes them, writing the resulting 76 characters
CRLF sequence into w
.
The last line may be less than 76 characters in length and will not end in CRLF.
ยงExamples
let input = "Hello!
You've got mail!
This one is base64 encoded.
Enjoy your bytes ๐ฌ๐ฌ๐ฌ";
let mut output = String::new();
email_encoding::body::base64::encode(input.as_bytes(), &mut output)?;
assert_eq!(
output,
concat!(
"SGVsbG8hCllvdSd2ZSBnb3QgbWFpbCEKVGhpcyBvbmUgaXMgYmFzZTY0IGVuY29kZWQuCgpFbmpv\r\n",
"eSB5b3VyIGJ5dGVzIPCfk6zwn5Os8J+TrA=="
)
);