Crates.io | deterministic-hash |
lib.rs | deterministic-hash |
version | 1.0.1 |
source | src |
created_at | 2021-07-12 11:02:08.889055 |
updated_at | 2021-07-12 11:08:48.901524 |
description | Create deterministic hashes regardless of architecture |
homepage | |
repository | https://github.com/Wassasin/deterministic-hash |
max_upload_size | |
id | 421855 |
size | 6,632 |
Tiny Rust library to create deterministic hashes regardless of architecture. This library is no-std
compatible and uses no allocations or dependencies.
The default core::hash::Hasher
implementation ensures a platform dependant hashing of datastructures that use #[derive(Hash)]
. Most notably by:
to_ne_bytes
for u{8,16,32,64,128}
.usize
.The DeterministicHasher
of this library forces the use of to_le_bytes
and casts usize
to 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.
You can validate the operation of this library with cross
by running:
cargo install cross
cross test --target=x86_64-unknown-linux-gnu
cross test --target=aarch64-unknown-linux-gnu
cross test --target=arm-unknown-linux-gnueabihf