Skip to main content

modo/encoding/
mod.rs

1//! # modo::encoding
2//!
3//! Binary-to-text encoding utilities.
4//!
5//! Provides three submodules:
6//!
7//! | Submodule     | Standard | Alphabet         | Padding | Extra            |
8//! | ------------- | -------- | ---------------- | ------- | ---------------- |
9//! | [`base32`]    | RFC 4648 | `A–Z`, `2–7`     | none    | —                |
10//! | [`base64url`] | RFC 4648 | `A–Za–z0–9-_`    | none    | —                |
11//! | [`hex`]       | —        | `0–9`, `a–f`     | —       | [`hex::sha256`]  |
12//!
13//! The [`base32`] and [`base64url`] submodules each expose an `encode` / `decode`
14//! pair. The [`hex`] submodule exposes `encode` (no `decode`) plus a convenience
15//! [`hex::sha256`] function that returns a 64-character hex digest.
16//!
17//! # Examples
18//!
19//! ```rust
20//! use modo::encoding::{base32, base64url, hex};
21//!
22//! let b32 = base32::encode(b"foobar");
23//! assert_eq!(b32, "MZXW6YTBOI");
24//!
25//! let b64 = base64url::encode(b"Hello");
26//! assert_eq!(b64, "SGVsbG8");
27//!
28//! let h = hex::encode(b"\xde\xad");
29//! assert_eq!(h, "dead");
30//!
31//! let digest = hex::sha256(b"hello world");
32//! assert_eq!(digest.len(), 64);
33//! ```
34
35pub mod base32;
36pub mod base64url;
37pub mod hex;