skillfed

dirhash

Python module and CLI for hashing of file system directories.

dirhash v0.5.0 13.3M downloads/30d#1,287 on PyPI60
Permissive license MIT DORMANT released

What it is and what it does

dirhash is a Python module and command-line tool that generates a single hash value representing the entire contents and structure of a directory. It uses Python's hashlib to support all standard hashing algorithms (MD5, SHA1, SHA256, etc.) and follows the Dirhash Standard for consistent, collision-resistant hashes across different implementations. The tool includes glob-style filtering to include or exclude files by pattern, and optional multiprocessing to parallelize hashing across files for performance gains.

The primary use case is verifying the integrity of a set of files and their directory structure—useful for validating datasets before expensive computations, regression testing, or ensuring that generated files match expected outputs. It addresses a gap in Python tooling by providing a well-tested, documented, and standardized approach to directory hashing, with a straightforward API for both programmatic and command-line use.

Use it for:

  • Verify dataset integrity before training a machine learning model to catch corrupted or missing files early.
  • Validate that generated output files in a regression test match a known-good directory hash.
  • Check that a downloaded or synced directory has not been modified or corrupted during transfer.
  • Exclude temporary or hidden files from a hash to focus on meaningful content changes.
  • Quickly detect structural changes in a large directory tree without comparing individual files.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Computes a single hash value for an entire directory based on its files' structure and content, supporting all hashlib algorithms and glob-style filtering.

Yes, if you need to verify directory integrity or detect changes in file structure and content. The low install friction, permissive license, and lack of security vulnerabilities make it safe to adopt. Dormant maintenance is a minor concern but not a blocker for a stable, single-purpose tool. Suitable for one-off verification tasks or as part of a larger testing pipeline.

Install

dirhash on PyPI

pip

pip install dirhash

uv

uv add dirhash

poetry

poetry add dirhash

Installing dirhash

Before you install

Low install friction with a single runtime dependency (scantree). Maintenance is dormant—last release was 2024-08-03, but the repository remains active and unarchived with no recent commits.

License in practice

MIT license is permissive, allowing use in commercial and proprietary projects with minimal restrictions.

Quickstart

pip install dirhash

from dirhash import dirhash

dir_md5 = dirhash('path/to/directory', 'md5')
pyfiles_md5 = dirhash('path/to/directory', 'md5', match=['*.py'])
no_hidden_sha1 = dirhash('path/to/directory', 'sha1', ignore=['.*', '.*/'])

Requires Python 3.8 or later.

Verify before relying

  • Whether multiprocessing speedup (up to 6x claimed) is achievable on typical modern hardware and directory sizes.
  • Collision resistance guarantees of the Dirhash Standard implementation in practice.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — scantree
Maintenance dormant — 741 days since the last release
Last repo commit
First released
Downloads 13,319,927/month — #1,287 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: dirhash-0.5.0-py3-none-any.whl

Tags

directory hash computationfolder integrity verificationrecursive file hashingdirectory checksumbulk file hashdataset integrity checkmultiprocessing directory hash
file-integrityhashingverification

More Quality Assurance packages