tiny-crypto 0.1.3

The tiny-crypto crate is a collection of tools for common crypto algorithms, with APIs aimed to be simple to use.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use base64ct::Encoding as _;

/// The Base64 encoder
pub struct Base64;

impl super::Encoder for Base64 {
    type Error = base64ct::Error;

    fn to_text(&self, input: &[u8]) -> String {
        base64ct::Base64::encode_string(input)
    }

    fn from_text(&self, input: &str) -> Result<Vec<u8>, Self::Error> {
        base64ct::Base64::decode_vec(input)
    }
}