zero_trust_rps/common/
utils.rs

1use rand::RngCore;
2use uuid::Uuid;
3
4use super::blake3::B3Hash;
5
6#[allow(unused)]
7pub fn get_random_bytes<const L: usize>() -> [u8; L] {
8    let mut data = [0; L];
9    rand::thread_rng().fill_bytes(&mut data);
10    data
11}
12
13/// IT should be sorted
14pub fn hash_users<IT: Iterator<Item = Uuid>>(it: IT) -> B3Hash {
15    let mut hasher = blake3::Hasher::new();
16    for uuid in it {
17        hasher.update(uuid.as_bytes());
18    }
19    hasher.finalize().into()
20}