Tiny Rust library to create deterministic hashes regardless of architecture. This library is
no-std compatible and uses no allocations or dependencies.
core::hash::Hasher implementation ensures a platform dependant hashing of datastructures that use
#[derive(Hash)]. Most notably by:
- using the native bytelength of
DeterministicHasher of this library forces the use of
to_le_bytes and casts
u64 regardless of your platform. Hence the hasher will be less efficient, but will be deterministic when using the same library in different architecture contexts. I use a common dataprotocol library both on ARM embedded systems, wasm and x64.
From any hasher make it deterministic by inserting
DeterministicHasher in between:
let hasher = crc::crc32::Digest::new(crc::crc32::KOOPMAN); let hasher = deterministic_hash::DeterministicHasher::new(hasher);
Wrapper around any hasher to make it deterministic.