Skip to content

Commit 6403a72

Browse files
authored
base64ct: add notes on crypt(3) alphabet variants (#2073)
Notes some additional algorithms that use the `Base64ShaCrypt` alphabet including `scrypt` and `yescrypt`, and also notes it's a little endian variant of Base64.
1 parent f5d4105 commit 6403a72

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

base64ct/src/alphabet/crypt.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ use super::{Alphabet, DecodeStep, EncodeStep};
88
/// [.-9] [A-Z] [a-z]
99
/// 0x2e-0x39, 0x41-0x5a, 0x61-0x7a
1010
/// ```
11+
///
12+
/// Note this encodes using a big endian variant of Base64. Most modern algorithms which can be
13+
/// used via `crypt(3)` use the little endian [`Base64ShaCrypt`][`crate::Base64ShaCrypt`] variant.
1114
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1215
pub struct Base64Crypt;
1316

base64ct/src/alphabet/shacrypt.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
33
use super::{Alphabet, DecodeStep, EncodeStep};
44

5-
/// `crypt(3)` Base64 encoding for the following schemes.
6-
/// * sha1_crypt,
7-
/// * sha256_crypt,
8-
/// * sha512_crypt,
9-
/// * md5_crypt
5+
/// Little endian variant of the `crypt(3)` Base64 encoding.
6+
///
7+
/// Used by the following schemes:
8+
/// - md5_crypt
9+
/// - scrypt
10+
/// - sha1_crypt
11+
/// - sha256_crypt
12+
/// - sha512_crypt
13+
/// - yescrypt
1014
///
1115
/// ```text
1216
/// [.-9] [A-Z] [a-z]
1317
/// 0x2e-0x39, 0x41-0x5a, 0x61-0x7a
1418
/// ```
19+
///
20+
/// This uses the same alphabet as [`Base64Crypt`][`crate::Base64Crypt`], but uses a little endian
21+
/// variant of Base64.
1522
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1623
pub struct Base64ShaCrypt;
1724

0 commit comments

Comments
 (0)