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
:
toml
[dependencies]
merkle_hash = "3.2"
Get the master hash of a directory tree:
```rust,norun use merklehash::{MerkleTree,Algorithm};
let tree = MerkleTree::builder("/path/to/directory") .algorithm(Algorithm::Blake3) .hashnames(false) .build()?; let masterhash = tree.main_node.item.hash; ```
Iterate over a directory tree, getting the hash of each file and directory:
```rust,norun use merklehash::{MerkleTree,bytestohex};
let tree = MerkleTree::builder("/path/to/directory").build()?; for item in tree { println!("{}: {}", item.path.relative, bytestohex(&item.hash)); } ```
Collapse the tree into any linear collection:
```rust,norun use std::collections::BTreeSet; use merklehash::{MerkleTree,MerkleItem};
let tree = MerkleTree::builder("/path/to/directory").build()?;
let btreeset: BTreeSet
Licensed under MIT license.