Expand description
Binary codec and fast hashing for event IDs.
Since room v3 an event ID is the eventβs sha256 reference hash: $ followed
by 43 characters of unpadded base64 (standard alphabet in v3, URL-safe in
v4+), so the 32 hash bytes and the ID convert losslessly in both directions.
TODO: Move this into Ruma and generalize for other identifiers.
Re-exportsΒ§
pub use crate::utils::hash::sha256::Digest as Sha256;
StructsΒ§
- Fold
Hasher - Streaming state for
RandomState. - Random
State BuildHasherfor event-ID-keyed maps and sets.
ConstantsΒ§
- ALPHABET_
LEN π - ALPHABET_
STANDARD π - ALPHABET_
URL_ πSAFE - ENCODED_
LEN π - INVALID π
- SEXTETS_
LEN π
StaticsΒ§
FunctionsΒ§
- decode
- Decode an event ID into the sha256 it encodes.
Noneunless the ID has the v3+ shape with canonical unpadded base64 in either alphabet. - decode_
bytes π - decode_
encoded π - encode
- Encode a sha256 into the URL-safe (room v4+) form of the event ID. A v3 (standard-alphabet) ID does not round-trip through this form.
- fold π
- fold_
bytes π - folded_
multiply π - hash_
bytes π - sextets π