blob: b3091d2a0c34f4d1172bb426784c24c576672123 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
//! Module implementing various hashing utilities.
use sha2::{Digest as _, Sha256};
use sha3::Keccak256;
/// Returns the Keccak-256 hash of the specified input.
pub fn keccak256(data: impl AsRef<[u8]>) -> [u8; 32] {
let mut hasher = Keccak256::new();
hasher.update(data.as_ref());
hasher.finalize().into()
}
/// Returns the SHA256 hash of the specified input.
pub fn sha256(data: impl AsRef<[u8]>) -> [u8; 32] {
let mut hasher = Sha256::new();
hasher.update(data.as_ref());
hasher.finalize().into()
}
|