Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use base64::{engine::general_purpose::STANDARD, Engine as _};

pub fn base64_decode(content: impl AsRef<str>) -> String {
    return STANDARD
        .decode(content.as_ref())
        .ok()
        .and_then(|bytes| String::from_utf8(bytes).ok())
        .expect("Error decoding base64!");
}

pub fn base64_encode(content: impl AsRef<str>) -> String {
    return STANDARD.encode(content.as_ref().as_bytes());
}