1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#[cfg(feature = "with-openssl")]
pub use openssl_compat::Sha1;
#[cfg(not(feature = "with-openssl"))]
pub use sha1::Sha1;
pub use sha2::{Sha256, Sha512};
pub use sha3::{Sha3_256, Shake128, Shake256};
#[cfg(feature = "with-openssl")]
mod openssl_compat {
use openssl::sha::Sha1 as OpenSslSha1;
use digest::{FixedOutput, HashMarker, Output, OutputSizeUser, Update};
#[derive(Default, Clone)]
pub struct Sha1(OpenSslSha1);
impl Update for Sha1 {
fn update(&mut self, data: &[u8]) {
self.0.update(data);
}
}
impl OutputSizeUser for Sha1 {
type OutputSize = typenum::consts::U20;
}
impl FixedOutput for Sha1 {
fn finalize_into(self, out: &mut Output<Self>) {
*out = self.0.finish().into();
}
}
impl HashMarker for Sha1 {}
}