Improve random key generation

This commit is contained in:
finga 2020-08-28 22:03:42 +02:00
parent 77e2108403
commit 5b3e56954e

View file

@ -60,11 +60,10 @@ fn reset_prepare(config: &Ldap0rConfig, keys: &Keys, email_address: &str) -> Res
if rs.len() == 1 { if rs.len() == 1 {
// generate key // generate key
let mut key = String::with_capacity(64);
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
for _ in 0..64 { let key: String = (0..64)
key.push(BASE62[rng.gen::<usize>() % 62] as char); .map(|_| BASE62[rng.gen::<usize>() % 62] as char)
} .collect();
// store key with id // store key with id
let keys = Arc::clone(&keys.keys); let keys = Arc::clone(&keys.keys);