use sha2::{Digest, Sha256};
pub fn compute_canonical_hash(payload: &[u8]) -> String {
let mut hasher = Sha256::new();
hasher.update(payload);
let result = hasher.finalize();
hex::encode(result)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_compute_canonical_hash() {
let data = "hello world";
let hash = compute_canonical_hash(data.as_bytes());
assert_eq!(hash, "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9");
}
}