Skip to content

Commit 97f5a05

Browse files
authored
Fix deprecation warnings (#319)
warning: use of deprecated function `base64::decode`: Use Engine::decode
1 parent 9830c18 commit 97f5a05

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/scram.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// https://github.com/sfackler/rust-postgres/
33
// SASL implementation.
44

5+
use base64::{engine::general_purpose, Engine as _};
56
use bytes::BytesMut;
67
use hmac::{Hmac, Mac};
78
use rand::{self, Rng};
@@ -81,7 +82,7 @@ impl ScramSha256 {
8182
return Err(Error::ProtocolSyncError(format!("SCRAM")));
8283
}
8384

84-
let salt = match base64::decode(&server_message.salt) {
85+
let salt = match general_purpose::STANDARD.decode(&server_message.salt) {
8586
Ok(salt) => salt,
8687
Err(_) => return Err(Error::ProtocolSyncError(format!("SCRAM"))),
8788
};
@@ -111,7 +112,7 @@ impl ScramSha256 {
111112
let mut cbind_input = vec![];
112113
cbind_input.extend("n,,".as_bytes());
113114

114-
let cbind_input = base64::encode(&cbind_input);
115+
let cbind_input = general_purpose::STANDARD.encode(&cbind_input);
115116

116117
self.message.clear();
117118

@@ -149,7 +150,11 @@ impl ScramSha256 {
149150
*proof ^= signature;
150151
}
151152

152-
match write!(&mut self.message, ",p={}", base64::encode(&*client_proof)) {
153+
match write!(
154+
&mut self.message,
155+
",p={}",
156+
general_purpose::STANDARD.encode(&*client_proof)
157+
) {
153158
Ok(_) => (),
154159
Err(_) => return Err(Error::ServerError),
155160
};
@@ -161,7 +166,7 @@ impl ScramSha256 {
161166
pub fn finish(&mut self, message: &BytesMut) -> Result<(), Error> {
162167
let final_message = FinalMessage::parse(message)?;
163168

164-
let verifier = match base64::decode(&final_message.value) {
169+
let verifier = match general_purpose::STANDARD.decode(&final_message.value) {
165170
Ok(verifier) => verifier,
166171
Err(_) => return Err(Error::ProtocolSyncError(format!("SCRAM"))),
167172
};

0 commit comments

Comments
 (0)