base64ct/alphabet/
crypt.rs

1//! `crypt(3)` Base64 encoding.
2
3use super::{Alphabet, DecodeStep, EncodeStep};
4
5/// `crypt(3)` Base64 encoding.
6///
7/// ```text
8/// [.-9]      [A-Z]      [a-z]
9/// 0x2e-0x39, 0x41-0x5a, 0x61-0x7a
10/// ```
11#[derive(Copy, Clone, Debug, Eq, PartialEq)]
12pub struct Base64Crypt;
13
14impl Alphabet for Base64Crypt {
15    const BASE: u8 = b'.';
16
17    const DECODER: &'static [DecodeStep] = &[
18        DecodeStep::Range(b'.'..=b'9', -45),
19        DecodeStep::Range(b'A'..=b'Z', -52),
20        DecodeStep::Range(b'a'..=b'z', -58),
21    ];
22
23    const ENCODER: &'static [EncodeStep] =
24        &[EncodeStep::Apply(b'9', 7), EncodeStep::Apply(b'Z', 6)];
25
26    const PADDED: bool = false;
27
28    type Unpadded = Self;
29}