Skip to content

Commit 2fd444e

Browse files
committed
Replace sha1 crate with sha-1
This other crate is being maintained, it offers better performances (when using the `asm` feature, especially [on AArch64](RustCrypto/hashes#97)). It also allows deduplicating SHA-1 crates in cargo-web.
1 parent e9a3c9c commit 2fd444e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

websocket-base/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ byteorder = "1.0"
2020
rand = "0.6.1"
2121
bitflags = "1.0.4"
2222
base64 = "0.10.0"
23-
sha1 = "0.6"
23+
sha-1 = "0.8"
2424
bytes = { version = "0.4", optional = true }
2525
futures = { version = "0.1", optional = true }
2626
native-tls = { version = "0.2.1", optional = true }

websocket-base/src/header.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub mod names {
1212

1313
extern crate base64;
1414
extern crate sha1;
15-
use self::sha1::Sha1;
15+
use sha1::{Sha1, Digest};
1616

1717
use crate::result::{WebSocketError, WebSocketResult};
1818
use std::fmt::{self, Debug};
@@ -105,10 +105,8 @@ impl WebSocketAccept {
105105
let mut concat_key = String::with_capacity(serialized.len() + 36);
106106
concat_key.push_str(&serialized[..]);
107107
concat_key.push_str(MAGIC_GUID);
108-
let mut sha1 = Sha1::new();
109-
sha1.update(concat_key.as_bytes());
110-
let bytes = sha1.digest().bytes();
111-
WebSocketAccept(bytes)
108+
let hash = Sha1::digest(concat_key.as_bytes());
109+
WebSocketAccept(hash.into())
112110
}
113111
/// Return the Base64 encoding of this WebSocketAccept
114112
pub fn serialize(&self) -> String {

0 commit comments

Comments
 (0)