hashdir2

Crates.iohashdir2
lib.rshashdir2
version0.1.2
created_at2025-10-18 23:09:28.652319+00
updated_at2025-10-18 23:14:13.043678+00
descriptionA fast, parallel, multi-algorithm directory hasher.
homepage
repositoryhttps://github.com/JerryImMouse/hashdir2
max_upload_size
id1889730
size50,202
Jerry (JerryImMouse)

documentation

README

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)

Commit count: 0

cargo fmt