Skip to content

Commit b2d76e4

Browse files
committed
Replace sha1 dependency with sha-1
This other crate is being maintained, and it offers better performances when using the `asm` feature (especially [on AArch64](RustCrypto/hashes#97)). Once websockets-rs/rust-websocket#251 is merged, it will also allow removing this extra crate from the build.
1 parent 2ddd9bb commit b2d76e4

4 files changed

Lines changed: 11 additions & 13 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ reqwest = "0.9"
2222
pbr = "1"
2323
libflate = "0.1"
2424
tar = "0.4"
25-
sha1 = "0.6"
25+
sha-1 = "0.8"
2626
sha2 = "0.8"
2727
digest = "0.8"
2828
toml = "0.4"

src/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::ffi::OsString;
77

88
use libflate::gzip;
99
use tar;
10-
use sha1::Sha1;
10+
use sha1::{Sha1, Digest};
1111

1212
#[derive(Debug)]
1313
pub struct ExecutionStatus {
@@ -106,9 +106,9 @@ pub fn get_sha1sum< P: AsRef< Path > >( path: P ) -> io::Result< String > {
106106
loop {
107107
match fp.read( &mut buffer )? {
108108
0 => break,
109-
count => hasher.update( &buffer[ 0..count ] )
109+
count => hasher.input( &buffer[ 0..count ] )
110110
}
111111
}
112112

113-
Ok( format!( "{}", hasher.digest() ) )
113+
Ok( format!( "{:x}", hasher.result() ) )
114114
}

src/wasm_inline_js.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22
use std::mem;
33

4-
use sha1::Sha1;
4+
use sha1::{Sha1, Digest};
55

66
use wasm_context::{
77
FnTy,
@@ -15,9 +15,8 @@ use wasm_context::{
1515
};
1616

1717
fn hash( string: &str ) -> String {
18-
let mut hasher = Sha1::new();
19-
hasher.update( string.as_bytes() );
20-
format!( "{}", hasher.digest() )
18+
let hash = Sha1::digest( string.as_bytes() );
19+
format!( "{:x}", hash )
2120
}
2221

2322
pub struct JsSnippet {

src/wasm_js_snippet.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::path::Path;
22
use std::fs;
33

4-
use sha1::Sha1;
4+
use sha1::{Sha1, Digest};
55
use serde_json;
66

77
use wasm_context::{Context, FunctionKind};
@@ -15,9 +15,8 @@ pub struct Snippet {
1515
}
1616

1717
fn hash( string: &str ) -> String {
18-
let mut hasher = Sha1::new();
19-
hasher.update( string.as_bytes() );
20-
format!( "{}", hasher.digest() )
18+
let hash = Sha1::digest( string.as_bytes() );
19+
format!( "{:x}", hash )
2120
}
2221

2322
pub fn process( target_dir: &Path, ctx: &Context ) -> Vec< JsSnippet > {
@@ -42,4 +41,4 @@ pub fn process( target_dir: &Path, ctx: &Context ) -> Vec< JsSnippet > {
4241
}
4342

4443
snippets
45-
}
44+
}

0 commit comments

Comments
 (0)