mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 13:37:48 +00:00
hashsum: re-factor SHA1 implementation into common macro
This commit is contained in:
parent
00d3c36e8c
commit
b1c543b4d2
1 changed files with 1 additions and 22 deletions
|
@ -104,28 +104,6 @@ impl Digest for blake3::Hasher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Digest for sha1::Sha1 {
|
|
||||||
fn new() -> Self {
|
|
||||||
Self::default()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn input(&mut self, input: &[u8]) {
|
|
||||||
digest::Digest::update(self, input);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn result(&mut self, out: &mut [u8]) {
|
|
||||||
digest::Digest::finalize_into_reset(self, out.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
fn reset(&mut self) {
|
|
||||||
*self = Self::new();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn output_bits(&self) -> usize {
|
|
||||||
160
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implements the Digest trait for sha2 / sha3 algorithms with fixed output
|
// Implements the Digest trait for sha2 / sha3 algorithms with fixed output
|
||||||
macro_rules! impl_digest_sha {
|
macro_rules! impl_digest_sha {
|
||||||
($type: ty, $size: expr) => {
|
($type: ty, $size: expr) => {
|
||||||
|
@ -180,6 +158,7 @@ macro_rules! impl_digest_shake {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_digest_sha!(sha1::Sha1, 160);
|
||||||
impl_digest_sha!(sha2::Sha224, 224);
|
impl_digest_sha!(sha2::Sha224, 224);
|
||||||
impl_digest_sha!(sha2::Sha256, 256);
|
impl_digest_sha!(sha2::Sha256, 256);
|
||||||
impl_digest_sha!(sha2::Sha384, 384);
|
impl_digest_sha!(sha2::Sha384, 384);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue