base64ct/alphabet/
crypt.rs

1//! `crypt(3)` Base64 encoding.
2
3#![allow(deprecated)]
4
5use super::{Alphabet, DecodeStep, EncodeStep};
6
7/// DEPRECATED: non-standard big endian variant of the `crypt(3)` Base64 encoding.
8///
9/// ```text
10/// [.-9]      [A-Z]      [a-z]
11/// 0x2e-0x39, 0x41-0x5a, 0x61-0x7a
12/// ```
13///
14/// <div class="warning">
15/// This encodes using a big endian variant of Base64. Most modern algorithms which can be
16/// used via `crypt(3)` use the [`Base64ShaCrypt`][`crate::Base64ShaCrypt`] encoding.
17/// </div>
18#[deprecated(
19    since = "1.8.2",
20    note = "non-standard encoding. Use Base64ShaCrypt for all crypt(3) algorithms"
21)]
22#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
23pub struct Base64Crypt;
24
25impl Alphabet for Base64Crypt {
26    const BASE: u8 = b'.';
27
28    const DECODER: &'static [DecodeStep] = &[
29        DecodeStep::Range(b'.'..=b'9', -45),
30        DecodeStep::Range(b'A'..=b'Z', -52),
31        DecodeStep::Range(b'a'..=b'z', -58),
32    ];
33
34    const ENCODER: &'static [EncodeStep] =
35        &[EncodeStep::Apply(b'9', 7), EncodeStep::Apply(b'Z', 6)];
36
37    const PADDED: bool = false;
38
39    type Unpadded = Self;
40}