ex3-crypto 0.15.21

EX3 crypto crate.
Documentation
pub fn keccak256(data: impl AsRef<[u8]>) -> [u8; 32] {
    use sha3::{Digest, Keccak256};
    let mut hasher = Keccak256::new();
    hasher.update(data);
    hasher.finalize().into()
}

#[cfg(test)]
mod tests {
    use super::keccak256;
    #[test]
    fn test_compute_hash() {
        let data = b"Hello, world!";
        keccak256(data);
        let hash: [u8; 32] = keccak256(data);
        assert_eq!(
            hash,
            [
                182, 225, 109, 39, 172, 90, 180, 39, 167, 246, 137, 0, 172, 85, 89, 206, 39, 45,
                198, 195, 124, 130, 179, 224, 82, 36, 108, 130, 36, 76, 80, 228
            ]
        );
    }
}