1 2 3 4 5 6 7 8 9 10 11 12
use rand::{Rng, distr::Alphanumeric, rng}; use std::iter; /// Generate random string of 64 chars for one-time token purposes. pub fn generate_code() -> String { let mut rng = rng(); iter::repeat(()) .map(|()| rng.sample(Alphanumeric)) .map(char::from) .take(64) .collect() }