Skip to content

Commit

Permalink
chore: addressed rand 0.9's deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
kristof-mattei committed Feb 1, 2025
1 parent e00ceb1 commit 02463b1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions postgres-protocol/src/authentication/sasl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ impl ScramSha256 {
/// Constructs a new instance which will use the provided password for authentication.
pub fn new(password: &[u8], channel_binding: ChannelBinding) -> ScramSha256 {
// rand 0.5's ThreadRng is cryptographically secure
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let nonce = (0..NONCE_LENGTH)
.map(|_| {
let mut v = rng.gen_range(0x21u8..0x7e);
let mut v = rng.random_range(0x21u8..0x7e);
if v == 0x2c {
v = 0x7e
}
Expand Down
2 changes: 1 addition & 1 deletion postgres-protocol/src/password/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const SCRAM_DEFAULT_SALT_LEN: usize = 16;
/// special characters that would require escaping in an SQL command.
pub fn scram_sha_256(password: &[u8]) -> String {
let mut salt: [u8; SCRAM_DEFAULT_SALT_LEN] = [0; SCRAM_DEFAULT_SALT_LEN];
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
rng.fill_bytes(&mut salt);
scram_sha_256_salt(password, salt)
}
Expand Down
4 changes: 2 additions & 2 deletions tokio-postgres/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ where

let mut indices = (0..num_hosts).collect::<Vec<_>>();
if config.load_balance_hosts == LoadBalanceHosts::Random {
indices.shuffle(&mut rand::thread_rng());
indices.shuffle(&mut rand::rng());
}

let mut error = None;
Expand Down Expand Up @@ -101,7 +101,7 @@ where
.collect::<Vec<_>>();

if config.load_balance_hosts == LoadBalanceHosts::Random {
addrs.shuffle(&mut rand::thread_rng());
addrs.shuffle(&mut rand::rng());
}

let mut last_err = None;
Expand Down

0 comments on commit 02463b1

Please sign in to comment.