| Crates.io | merkle_hash |
| lib.rs | merkle_hash |
| version | 3.8.0 |
| created_at | 2022-03-18 21:56:07.542912+00 |
| updated_at | 2025-03-30 13:30:12.035004+00 |
| description | Finds the hashes of all files and directories in a directory tree. |
| homepage | https://github.com/hristogochev/merkle_hash |
| repository | https://github.com/hristogochev/merkle_hash |
| max_upload_size | |
| id | 552922 |
| size | 38,776 |
Finds the hashes of all files and directories in a directory tree.
To use this crate, add merkle_hash as a dependency to your project's Cargo.toml:
[dependencies]
merkle_hash = "3.8"
sha - Add this cargo feature to include SHA-256 and SHA-512 as hashing algorithms.parallel - Enabled by default, this feature makes the crate utilize all available threads.camino - Enabled by default, this feature makes all paths UTF-8 validated.encode - Enabled by default, this feature adds the bytes_to_hex and to_hex_string functions.retain - Disabled by default, this feature duplicates the children paths of directories upon traversal.bincode - Disabled by default, this feature enables bincode support.Get the master hash of a directory tree:
use merkle_hash::{Algorithm, MerkleTree};
let tree = MerkleTree::builder("/path/to/directory")
.algorithm(Algorithm::Blake3)
.hash_names(false)
.build()?;
let master_hash = tree.root.item.hash;
Iterate over a directory tree, getting the hash of each file and directory:
use merkle_hash::{Encodable, MerkleTree};
let tree = MerkleTree::builder("/path/to/directory").build()?;
for item in tree {
println!("{}: {}", item.path.relative, item.hash.to_hex_string());
}
Collapse the tree into any linear collection:
use std::collections::BTreeSet;
use merkle_hash::{MerkleItem, MerkleTree};
let tree = MerkleTree::builder("/path/to/directory").build()?;
let btree_set: BTreeSet<MerkleItem> = tree.into_iter().collect();
Licensed under MIT license.