Skip to main content

random_string

Function random_string 

Source
pub fn random_string(len: usize) -> String
Expand description

Generates a random alphanumeric string of the given length.

Uses rand::thread_rng (OS CSPRNG) and the Alphanumeric distribution (a–z, A–Z, 0–9). Each character provides ~5.95 bits of entropy.

§Example

// Module is crate-private; use from within beam.
let id = beam::utils::random_string(32);
assert_eq!(id.len(), 32);