pub(crate) fn machine_hash(tenant_id: &str, product_id: &str, stable_id: &str) -> String {
use sha2::{Digest, Sha256};
let material = format!("keylight-keyless-machine-v1|{tenant_id}|{product_id}|{stable_id}");
let digest = Sha256::digest(material.as_bytes());
digest.iter().map(|b| format!("{b:02x}")).collect()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn canonical_hash_matches_cross_sdk_test_vector() {
assert_eq!(
machine_hash("testco", "testapp", "hardware-1"),
"8e8871112f28cabda180ada131d0b4f4f07c72fb47c5d884edbe32812885b22a"
);
}
}