Skip to content

Commit 02463b1

Browse files
chore: addressed rand 0.9's deprecations
1 parent e00ceb1 commit 02463b1

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

postgres-protocol/src/authentication/sasl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ impl ScramSha256 {
136136
/// Constructs a new instance which will use the provided password for authentication.
137137
pub fn new(password: &[u8], channel_binding: ChannelBinding) -> ScramSha256 {
138138
// rand 0.5's ThreadRng is cryptographically secure
139-
let mut rng = rand::thread_rng();
139+
let mut rng = rand::rng();
140140
let nonce = (0..NONCE_LENGTH)
141141
.map(|_| {
142-
let mut v = rng.gen_range(0x21u8..0x7e);
142+
let mut v = rng.random_range(0x21u8..0x7e);
143143
if v == 0x2c {
144144
v = 0x7e
145145
}

postgres-protocol/src/password/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const SCRAM_DEFAULT_SALT_LEN: usize = 16;
2828
/// special characters that would require escaping in an SQL command.
2929
pub fn scram_sha_256(password: &[u8]) -> String {
3030
let mut salt: [u8; SCRAM_DEFAULT_SALT_LEN] = [0; SCRAM_DEFAULT_SALT_LEN];
31-
let mut rng = rand::thread_rng();
31+
let mut rng = rand::rng();
3232
rng.fill_bytes(&mut salt);
3333
scram_sha_256_salt(password, salt)
3434
}

tokio-postgres/src/connect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ where
4444

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

5050
let mut error = None;
@@ -101,7 +101,7 @@ where
101101
.collect::<Vec<_>>();
102102

103103
if config.load_balance_hosts == LoadBalanceHosts::Random {
104-
addrs.shuffle(&mut rand::thread_rng());
104+
addrs.shuffle(&mut rand::rng());
105105
}
106106

107107
let mut last_err = None;

0 commit comments

Comments
 (0)