Skip to main content

Crate mod_rand

Crate mod_rand 

Source
Expand description

§mod-rand

Tiered random number generation for Rust. Zero dependencies. Pick the tier appropriate to your threat model.

§Tiers

  • tier1: Deterministic seedable PRNG (xoshiro256**). For simulation, fixture data, non-security shuffling. Always available, works in no_std.
  • tier2: Process-unique seeds derived from PID + time + counter. For tempdir names, request IDs, log correlation. Fast enough for high-frequency use. Not cryptographic.
  • tier3: OS-backed cryptographic random. For tokens, keys, session IDs. Calls platform syscalls directly.

§Quick example

use mod_rand::tier1::Xoshiro256;

let mut rng = Xoshiro256::seed_from_u64(42);
let n: u64 = rng.next_u64();

§Choosing a tier

Use caseTier
Test fixtures, simulation1
Tempdir names, request IDs2
Auth tokens, session IDs, keys3

§Status

v0.1.0 is a placeholder release. Real implementation lands in 0.9.x. See the CHANGELOG for what’s stable.

Modules§

tier1
Tier 1 — Fast deterministic PRNG
tier2tier2
Tier 2 — Process-unique seeds
tier3tier3
Tier 3 — OS-backed cryptographic random