1 stable release
1.0.0 | Oct 12, 2024 |
---|
#889 in Data structures
154 downloads per month
30KB
512 lines
merkle-root
Library for calculating the Merkle root of either a file, or walked directory.
Supports both xxHash
(non-cryptographic) and SHA2-256
.
- Files are split into 8kb blocks, then recursively hashed.
- Walked "directories" are hashes into
n
arbitrary levels. Individual files can be "tested" for inclusion inO(n * log n)
time.
use merkle_root::MerkleTree;
let data_to_hash = [0xffu8; 8192];
let tree = MerkleTree::from_reader(&data_to_hash[..]).unwrap();
assert_eq!(
tree.root(),
hex::decode("68d131bc271f9c192d4f6dcd8fe61bef90004856da19d0f2f514a7f4098b0737").unwrap()
);
Meta
This library is forked from Fuchsia.
Changes:
- Support for non-cryptographic hashes (
xxhash-rust
). - Create a
MerkleTree
from a walked directory.
License
This work is originally under the BSD License.
Any new contributions are under the MIT License.
Dependencies
~550KB
~12K SLoC