use crate::tools::types::Hash;
pub fn hash(data: &[u8]) -> Hash {
let mut hasher = blake3::Hasher::new();
hasher.update(data);
let hash = hasher.finalize();
Hash(hash.into())
}
pub fn hash_two(data_1: &[u8], data_2: &[u8]) -> Hash {
let mut hasher = blake3::Hasher::new();
hasher.update(data_1);
hasher.update(data_2);
let hash = hasher.finalize();
Hash(hash.into())
}
pub fn hash_multiple(datas: &[&[u8]]) -> Hash {
let mut hasher = blake3::Hasher::new();
for &data in datas {
hasher.update(data);
}
let hash = hasher.finalize();
Hash(hash.into())
}
pub fn hash_multiple_plus_one(datas: &[&[u8]], data_plus_one: &[u8]) -> Hash {
let mut hasher = blake3::Hasher::new();
for &data in datas {
hasher.update(data);
}
hasher.update(data_plus_one);
let hash = hasher.finalize();
Hash(hash.into())
}