Fast and lightweight random number generator library and CLI tool for Rust.
- Small single-state RNG
- Fast bulk operations
- Pure Rust implementation
no_stdsupport- Installable CLI tool
[dependencies]
ax-rnd = "0.1"cargo install ax-rnduse ax_rnd::{
u32,
u64,
bool,
f64,
alphanumeric,
base64url,
fill,
};
let n = u64();
let ok = bool();
let token = alphanumeric(32);
let url = base64url(32);
let mut buf = [0u8; 1024];
fill(&mut buf);use ax_rnd::rng;
let mut rng = rng(12345);
let x = rng.next_u64();
let y = rng.next_u32();
let f = rng.next_f64();use ax_rnd::rng;
let mut rng = rng(42);
let x = rng.bounded_u64(100);
let y = rng.bounded_u32(50);use ax_rnd::rng;
let mut rng = rng(42);
let alpha = rng.alpha(32);
let token = rng.token(32);use ax_rnd::rng;
let mut rng = rng(42);
let mut bytes = [0u8; 1024];
rng.fill_bytes(&mut bytes);
let mut u64s = [0u64; 16];
rng.fill_u64(&mut u64s);use ax_rnd::AxRng;
let mut rng = AxRng::new(12345);
let state = rng.state();
let restored = AxRng::from_raw(state[0]);
let other = rng.split();
rng.reseed(999);use ax_rnd;
let x = ax_rnd::random_u64(42);
let token = ax_rnd::token(42, 32);
let bounded = ax_rnd::bounded_u64(42, 100);ax_rnd <command> [args]| Command | Description |
|---|---|
bytes |
Generate random bytes |
alpha |
Generate alphanumeric string |
token |
Generate URL-safe token |
shuffle |
Shuffle input lines |
u64 |
Generate random numbers |
uuid |
Generate UUID v4 |
ax_rnd bytes 32 --hex
ax_rnd alpha 16
ax_rnd token 32
ax_rnd u64 5
ax_rnd uuid 3- Deterministic when using fixed seeds
- Portable pure Rust implementation
- Suitable for fast non-cryptographic randomness
- Supports
no_std
- Crate: https://crates.io/crates/ax-rnd
- Docs: https://docs.rs/ax-rnd
- Rust: https://www.rust-lang.org
MIT