1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use uuid::Uuid;

pub fn hash_anonymous_identifier(
    course_id: Uuid,
    hashing_key_for_the_day: Vec<u8>,
    user_agent: String,
    ip_address: String,
) -> anyhow::Result<String> {
    let mut hasher = blake3::Hasher::new();
    hasher.update(course_id.as_bytes());
    hasher.update(&hashing_key_for_the_day);
    hasher.update(ip_address.as_bytes());
    hasher.update(user_agent.as_bytes());
    let hash = hasher.finalize();
    let res = hash.to_hex().to_string();
    Ok(res)
}