Expand description
aria-bsv-hasher — Canonical JSON serialization and SHA-256 hashing.
Implements the ARIA BRC-121 canonical JSON format, which is identical
to the Python SDK’s canonical_json(): object keys are sorted
lexicographically, arrays preserve order, and output is UTF-8 bytes
with no whitespace.
§Example
use aria_bsv_hasher::{hash_object, hash_bytes, prefixed_hash};
use serde_json::json;
let h = hash_object(&json!({"b": 2, "a": 1})).unwrap();
assert_eq!(h.len(), 64); // lowercase hex SHA-256
// Same result as: hash_bytes(b"{\"a\":1,\"b\":2}")
let direct = hash_bytes(b"{\"a\":1,\"b\":2}");
assert_eq!(h, direct);
assert_eq!(prefixed_hash(&h), format!("sha256:{}", h));Enums§
- Hasher
Error - Errors produced by the hasher.
Functions§
- canonical_
json - Serialize
vto deterministic JSON bytes. - equal
- Compare two SHA-256 hex strings in a case-insensitive way.
- hash_
bytes - Hash raw bytes with SHA-256. Returns lowercase hex.
- hash_
object - Canonicalize
vand return SHA-256 hex of the canonical bytes. - hash_
object_ prefixed - Canonicalize and hash
v, returning"sha256:<hex>". - hash_
string - Hash a UTF-8 string with SHA-256. Returns lowercase hex.
- must_
hash_ object - Like
hash_objectbut panics on error (useful in tests / infallible contexts). - prefixed_
hash - Prepend
"sha256:"tohash. Does not validatehash.