#blake3 #checksum #directory-checksum #directory #checksum-blake3

bin+lib hashdir2

A fast, parallel, multi-algorithm directory hasher

2 releases

Uses new Rust 2024

0.1.2 Oct 18, 2025
0.1.1 Oct 18, 2025

#653 in Filesystem

Custom license

31KB
745 lines

hashdir2

A fast, parallel, multi-algorithm directory hashing library and CLI.

hashdir2 provides both a library and a command-line tool for hashing directories recursively using multiple algorithms. It is designed to be efficient, deterministic, and suitable for use in automated environments such as CI/CD pipelines.

Overview

  • Recursive directory traversal
  • Parallel hashing using rayon
  • Multiple algorithms: SHA-2, BLAKE2, BLAKE3, MD5
  • Memory-mapped I/O for large files
  • Deterministic output
  • Optional CLI with progress indication and verification

[!IMPORTANT]
This library is very raw and there are could be some critical bugs not found yet. Keep that in mind when working with it.

Installation

Library

Add to Cargo.toml:

[dependencies]
hashdir2 = "0.1"

Command-line tool

To install the CLI binary:

cargo install hashdir2

After installation:

hashdir2 --help

Example (library)

use hashdir2::hash::blake3::Blake3Hasher;
use hashdir2::walk::{DirHasher, WalkEvent};

fn main() -> std::io::Result<()> {
    let hasher = DirHasher::new(Blake3Hasher::new());

    let root_hash = hasher.walk("./target", |event| {
        if let WalkEvent::File { path, .. } = event {
            println!("hashed: {}", path.display());
        }
    }, None)?;

    println!("root hash: {:x?}", root_hash);
    Ok(())
}

Example (CLI)

Hash a directory:

hashdir2 /path/to/dir

Select algorithm:

hashdir2 --algo blake3 /path/to/dir

Verify against a known hash:

hashdir2 --verify expected.txt /path/to/dir

Output in base64:

hashdir2 --format base64 /path/to/dir

Feature flags

Feature Description
default Enables the cli feature
cli Enables the command-line interface and dependencies (clap, indicatif, hex, base64)

Example disabling the CLI:

[dependencies]
hashdir2 = { version = "0.1", default-features = false }

Roadmap?

  • Cover everything with unit-tests to make the library behaviour more predictable
  • Add glob pattern matching
  • Add symlink follow behaviour

License

Licensed under MIT license (LICENSE)

Dependencies

~3.5–7MB
~145K SLoC