Skip to content

Commit

Permalink
Switch from base64 0.20 to data-encoding 2
Browse files Browse the repository at this point in the history
base64 0.21 deprecated the simple API and requires quite a bit more code
for the simple usage here, while data-encoding provides exactly the API
needed and is also actively maintained.
  • Loading branch information
sdroege authored and daniel-abramov committed Jan 15, 2023
1 parent c469214 commit c6769e3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ all-features = true

[features]
default = ["handshake"]
handshake = ["base64", "http", "httparse", "sha1", "url"]
handshake = ["data-encoding", "http", "httparse", "sha1", "url"]
native-tls = ["native-tls-crate"]
native-tls-vendored = ["native-tls", "native-tls-crate/vendored"]
rustls-tls-native-roots = ["__rustls-tls", "rustls-native-certs"]
rustls-tls-webpki-roots = ["__rustls-tls", "webpki-roots"]
__rustls-tls = ["rustls", "webpki"]

[dependencies]
base64 = { version = "0.20.0", optional = true }
data-encoding = { version = "2", optional = true }
byteorder = "1.3.2"
bytes = "1.0"
http = { version = "0.2", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion src/handshake/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pub fn generate_key() -> String {
// a base64-encoded (see Section 4 of [RFC4648]) value that,
// when decoded, is 16 bytes in length (RFC 6455)
let r: [u8; 16] = rand::random();
base64::encode(&r)
data_encoding::BASE64.encode(&r)
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion src/handshake/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn derive_accept_key(request_key: &[u8]) -> String {
let mut sha1 = Sha1::default();
sha1.update(request_key);
sha1.update(WS_GUID);
base64::encode(&sha1.finalize())
data_encoding::BASE64.encode(&sha1.finalize())
}

#[cfg(test)]
Expand Down

0 comments on commit c6769e3

Please sign in to comment.