Skip to content

Commit ee329f8

Browse files
Ayush1325seanmonstar
authored andcommitted
Update base64 to 0.21 (hyperium#127)
Signed-off-by: Ayush Singh <[email protected]> Co-authored-by: Sean McArthur <[email protected]>
1 parent 1dd7f50 commit ee329f8

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ members = [
1919

2020
[dependencies]
2121
http = "0.2.0"
22-
headers-core = "0.2"
23-
base64 = "0.13"
22+
headers-core = { version = "0.2" }
23+
base64 = "0.21.3"
2424
bytes = "1"
2525
mime = "0.3.14"
2626
sha1 = "0.10"

src/common/authorization.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Authorization header and types.
22
3-
use base64;
3+
use base64::engine::general_purpose::STANDARD as ENGINE;
4+
use base64::Engine;
45
use bytes::Bytes;
56

67
use util::HeaderValueString;
@@ -158,7 +159,8 @@ impl Credentials for Basic {
158159
let bytes = &value.as_bytes()["Basic ".len()..];
159160
let non_space_pos = bytes.iter().position(|b| *b != b' ')?;
160161
let bytes = &bytes[non_space_pos..];
161-
let bytes = base64::decode(bytes).ok()?;
162+
163+
let bytes = ENGINE.decode(bytes).ok()?;
162164

163165
let decoded = String::from_utf8(bytes).ok()?;
164166

@@ -169,7 +171,7 @@ impl Credentials for Basic {
169171

170172
fn encode(&self) -> HeaderValue {
171173
let mut encoded = String::from("Basic ");
172-
base64::encode_config_buf(&self.decoded, base64::STANDARD, &mut encoded);
174+
ENGINE.encode_string(&self.decoded, &mut encoded);
173175

174176
let bytes = Bytes::from(encoded);
175177
HeaderValue::from_maybe_shared(bytes)

src/common/sec_websocket_accept.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use base64;
1+
use base64::engine::general_purpose::STANDARD as ENGINE;
2+
use base64::Engine;
23
use bytes::Bytes;
34
use sha1::{Digest, Sha1};
45

@@ -39,7 +40,7 @@ fn sign(key: &[u8]) -> SecWebsocketAccept {
3940
let mut sha1 = Sha1::default();
4041
sha1.update(key);
4142
sha1.update(&b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"[..]);
42-
let b64 = Bytes::from(base64::encode(&sha1.finalize()));
43+
let b64 = Bytes::from(ENGINE.encode(&sha1.finalize()));
4344

4445
let val = ::HeaderValue::from_maybe_shared(b64).expect("base64 is a valid value");
4546

0 commit comments

Comments
 (0)