Skip to main content

loonfs_api/
digest.rs

1//! The `sha256:<64hex>` digest form durable formats use.
2
3use sha2::{Digest, Sha256};
4
5/// Computes the durable `sha256:` digest spelling used by envelope payloads
6/// and local compare tokens.
7pub fn sha256_digest(bytes: &[u8]) -> String {
8    format!("sha256:{}", sha256_hex(bytes))
9}
10
11pub(crate) fn sha256_hex(bytes: &[u8]) -> String {
12    crate::hex::hex_encode_bytes(&Sha256::digest(bytes))
13}