diff --git a/examples/scram.rs b/examples/scram.rs index 6e4ad1a9..3b0c089d 100644 --- a/examples/scram.rs +++ b/examples/scram.rs @@ -36,11 +36,7 @@ impl SimpleQueryHandler for DummyProcessor { } pub fn random_salt() -> Vec { - let mut buf = vec![0u8; 10]; - for v in buf.iter_mut() { - *v = rand::random::(); - } - buf + Vec::from(rand::random::<[u8; 10]>()) } const ITERATIONS: usize = 4096; diff --git a/src/api/auth/scram.rs b/src/api/auth/scram.rs index 1903af16..d60c4af3 100644 --- a/src/api/auth/scram.rs +++ b/src/api/auth/scram.rs @@ -63,12 +63,7 @@ pub fn gen_salted_password(password: &str, salt: &[u8], iters: usize) -> Vec } pub fn random_nonce() -> String { - let mut buf = [0u8; 18]; - for v in buf.iter_mut() { - *v = rand::random::(); - } - - STANDARD.encode(buf) + STANDARD.encode(rand::random::<[u8; 18]>()) } impl SASLScramAuthStartupHandler {