Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/revlog/path_encode.rs @ 47380:fad504cfc94b
rust: Use a maintained crate for SHA-1 hashing
https://crates.io/crates/rust-crypto hasn?t been updated in 5 years.
This doesn?t neccesarily mean there?s anything wrong with it, but if
something comes up it?s preferable to rely on libraries that have active
maintainers.
Use https://crates.io/crates/sha-1 from https://github.com/RustCrypto instead
Differential Revision: https://phab.mercurial-scm.org/D10835
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 02 Jun 2021 10:00:50 +0200 |
parents | aebc976fd7d5 |
children | e98fd81bb151 |
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/path_encode.rs Wed Jun 02 18:03:43 2021 +0200 +++ b/rust/hg-core/src/revlog/path_encode.rs Wed Jun 02 10:00:50 2021 +0200 @@ -1,5 +1,4 @@ -use crypto::digest::Digest; -use crypto::sha1::Sha1; +use sha1::{Digest, Sha1}; #[derive(PartialEq, Debug)] #[allow(non_camel_case_types)] @@ -621,13 +620,7 @@ panic!("path_encode::hash_encore: string too long: {}", baselen) }; let dirlen = encode_dir(Some(&mut dired[..]), src); - let sha = { - let mut hasher = Sha1::new(); - hasher.input(&dired[..dirlen]); - let mut hash = vec![0; 20]; - hasher.result(&mut hash); - hash - }; + let sha = Sha1::digest(&dired[..dirlen]); let lowerlen = lower_encode(Some(&mut lowered[..]), &dired[..dirlen][5..]); let auxlen = aux_encode(Some(&mut auxed[..]), &lowered[..lowerlen]); hash_mangle(&auxed[..auxlen], &sha)