diff --git a/Cargo.toml b/Cargo.toml index 4bf125a..c705856 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ reqwest = "0.9" pbr = "1" libflate = "0.1" tar = "0.4" -sha1 = "0.6" +sha-1 = "0.8" sha2 = "0.8" digest = "0.8" toml = "0.4" diff --git a/src/utils.rs b/src/utils.rs index ef22318..e7c13f9 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -7,7 +7,7 @@ use std::ffi::OsString; use libflate::gzip; use tar; -use sha1::Sha1; +use sha1::{Sha1, Digest}; #[derive(Debug)] pub struct ExecutionStatus { @@ -106,9 +106,9 @@ pub fn get_sha1sum< P: AsRef< Path > >( path: P ) -> io::Result< String > { loop { match fp.read( &mut buffer )? { 0 => break, - count => hasher.update( &buffer[ 0..count ] ) + count => hasher.input( &buffer[ 0..count ] ) } } - Ok( format!( "{}", hasher.digest() ) ) + Ok( format!( "{:x}", hasher.result() ) ) } diff --git a/src/wasm_inline_js.rs b/src/wasm_inline_js.rs index 4102c89..e90d741 100644 --- a/src/wasm_inline_js.rs +++ b/src/wasm_inline_js.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::mem; -use sha1::Sha1; +use sha1::{Sha1, Digest}; use wasm_context::{ FnTy, @@ -15,9 +15,8 @@ use wasm_context::{ }; fn hash( string: &str ) -> String { - let mut hasher = Sha1::new(); - hasher.update( string.as_bytes() ); - format!( "{}", hasher.digest() ) + let hash = Sha1::digest( string.as_bytes() ); + format!( "{:x}", hash ) } pub struct JsSnippet { diff --git a/src/wasm_js_snippet.rs b/src/wasm_js_snippet.rs index 5d23d36..1f361d6 100644 --- a/src/wasm_js_snippet.rs +++ b/src/wasm_js_snippet.rs @@ -1,7 +1,7 @@ use std::path::Path; use std::fs; -use sha1::Sha1; +use sha1::{Sha1, Digest}; use serde_json; use wasm_context::{Context, FunctionKind}; @@ -15,9 +15,8 @@ pub struct Snippet { } fn hash( string: &str ) -> String { - let mut hasher = Sha1::new(); - hasher.update( string.as_bytes() ); - format!( "{}", hasher.digest() ) + let hash = Sha1::digest( string.as_bytes() ); + format!( "{:x}", hash ) } pub fn process( target_dir: &Path, ctx: &Context ) -> Vec< JsSnippet > { @@ -42,4 +41,4 @@ pub fn process( target_dir: &Path, ctx: &Context ) -> Vec< JsSnippet > { } snippets -} \ No newline at end of file +}