secure_gate/random/
mod.rs

1// secure-gate/src/random/mod.rs
2//! Cryptographically secure random value generation with encoding conveniences (gated behind “rand” and encoding features).
3//!
4//! Provides `FixedRng` and `DynamicRng` types for generating fresh random bytes.
5//! Includes built-in methods for encoding to Hex, Base64, Bech32, and Bech32m strings
6//! without exposing secret bytes.
7//!
8//! # Examples
9//!
10//! Generate and encode random bytes:
11//! ```
12//! # #[cfg(all(feature = "rand", feature = "encoding-hex"))]
13//! # {
14//! use secure_gate::random::FixedRng;
15//! let hex = FixedRng::<32>::generate().into_hex();
16//! # }
17//! ```
18//!
19//! Use with Base64:
20//! ```
21//! # #[cfg(all(feature = "rand", feature = "encoding-base64"))]
22//! # {
23//! use secure_gate::random::FixedRng;
24//! let base64 = FixedRng::<32>::generate().into_base64();
25//! # }
26//! ```
27//!
28//! Encode to Bech32 or Bech32m:
29//! ```
30//! # #[cfg(all(feature = "rand", feature = "encoding-bech32"))]
31//! # {
32//! use secure_gate::random::FixedRng;
33//! let bech32 = FixedRng::<32>::generate().into_bech32("example");
34//! let bech32m = FixedRng::<32>::generate().into_bech32m("example");
35//! # }
36//! ```
37
38pub mod dynamic_rng;
39pub mod fixed_rng;
40
41// Re-export for API compatibility
42pub use dynamic_rng::DynamicRng;
43pub use fixed_rng::FixedRng;