Skip to content

Commit

Permalink
Merge pull request #587 from uuid-rs/feat/fast-sha1
Browse files Browse the repository at this point in the history
Use the sha1_smol library for SHA1
  • Loading branch information
KodrAus authored Feb 28, 2022
2 parents 5aa53c8 + 165b7eb commit f0d5956
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ js = ["private_getrandom", "private_getrandom/js"]
rng = ["private_getrandom"]
fast-rng = ["rng", "private_rand"]

sha1 = ["private_sha1"]
sha1 = ["private_sha1_smol"]
md5 = ["private_md-5"]

# Public: Used in trait impls on `Uuid`
Expand Down Expand Up @@ -121,11 +121,11 @@ version = "0.10"
# Private
# Don't depend on this optional feature directly: it may change at any time
# Use the `sha1` feature instead
[dependencies.private_sha1]
package = "sha1"
[dependencies.private_sha1_smol]
package = "sha1_smol"
default-features = false
optional = true
version = "0.10"
version = "1"

# Public: Re-exported
# Don't depend on this optional feature directly: it may change at any time
Expand Down
4 changes: 2 additions & 2 deletions src/sha1.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#[cfg(feature = "v5")]
pub(crate) fn hash(ns: &[u8], src: &[u8]) -> [u8; 16] {
use private_sha1::{Sha1, Digest};
use private_sha1_smol::Sha1;

let mut hasher = Sha1::new();

hasher.update(ns);
hasher.update(src);

let mut bytes = [0; 16];
bytes.copy_from_slice(&hasher.finalize()[..16]);
bytes.copy_from_slice(&hasher.digest().bytes()[..16]);

bytes
}

0 comments on commit f0d5956

Please sign in to comment.