Maybe more rustic way of building a random password.
This commit is contained in:
parent
8b6078fb7d
commit
5217b51926
@ -46,6 +46,8 @@ fn random_password(len: usize) -> String {
|
||||
let rng = thread_rng();
|
||||
// Note; I would like to have lowercase letters more probable
|
||||
use rand::distributions::Alphanumeric;
|
||||
String::from_utf8(rng.sample_iter(&Alphanumeric).take(len).collect())
|
||||
.unwrap()
|
||||
rng.sample_iter(&Alphanumeric)
|
||||
.map(char::from)
|
||||
.take(len)
|
||||
.collect()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user