53fc84a270
Add token, hex, and pin helpers for the common ASCII string formats already represented by the crate's built-in charsets. These methods keep frequent use cases concise while continuing to route through string_from, so callers still get the same uniform per-character sampling behavior. Avoid adding a password preset in this change. Password generation implies policy choices around symbols, ambiguous characters, and service-specific constraints, while these presets are direct names for existing alphabets. Document every preset with doctested examples and add a runnable presets example. Update the demo to show both presets and custom string generation. Test Plan: - cargo test - cargo clippy - cargo clippy --benches - cargo clippy --tests - cargo +nightly fmt Refs: IDEAS.md ergonomics backlog
18 lines
342 B
Rust
18 lines
342 B
Rust
//! Run with: `cargo run --example presets`
|
|
|
|
use ez_urandom::OsRandom;
|
|
|
|
fn main() -> std::io::Result<()> {
|
|
let mut rng = OsRandom::try_new()?;
|
|
|
|
let token = rng.token(24)?;
|
|
let hex = rng.hex(32)?;
|
|
let pin = rng.pin(6)?;
|
|
|
|
println!("token: {token}");
|
|
println!("hex : {hex}");
|
|
println!("pin : {pin}");
|
|
|
|
Ok(())
|
|
}
|