MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / content_hash

Function content_hash

atomic-canonical/src/hash.rs:16–20  ·  view source on GitHub ↗

The `blake3: ` content hash of a JSON value's canonical form.

(value: &Value)

Source from the content-addressed store, hash-verified

14
15/// The `blake3:<hex>` content hash of a JSON value's canonical form.
16pub fn content_hash(value: &Value) -> String {
17 let canonical = jcs::canonicalize(value);
18 let digest = blake3::hash(canonical.as_bytes());
19 format!("blake3:{}", digest.to_hex())
20}
21
22#[cfg(test)]
23mod tests {

Callers 4

compute_content_hashMethod · 0.85
compute_content_hashMethod · 0.85
attest_valueFunction · 0.85
verify_valueFunction · 0.85

Calls 3

canonicalizeFunction · 0.85
hashFunction · 0.85
as_bytesMethod · 0.45

Tested by

no test coverage detected