ruc 10.0.0

Rust Util Collections
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use sha3::{Digest, Keccak256};

/// The `Keccak` hash output type.
pub type KeccakHash = [u8; 32];

pub fn hash_msg(msg: &[&[u8]]) -> KeccakHash {
    let mut hasher = Keccak256::new();

    msg.iter().for_each(|i| {
        hasher.update(i);
    });
    *hasher.finalize().as_ref()
}

#[inline(always)]
pub fn hash(i: &[u8]) -> KeccakHash {
    hash_msg(&[i])
}