Improve random key generation

This commit is contained in:
finga 2020-08-28 22:03:42 +02:00
parent cb9efb4f01
commit c4bbfc12a1

View file

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