Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the sha1_smol library for SHA1 #587

Merged
merged 1 commit into from Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
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
@@ -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
}