dirhash
Python module and CLI for hashing of file system directories.
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 dirhashuv
uv add dirhashpoetry
poetry add dirhashInstalling 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
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
checksumdirComputes a single hash digest of all file…
permissive · top 15,000 on PyPI
filehashCalculates and verifies file checksums and…
permissive · top 15,000 on PyPI
provide-dirCreates a directory and all its parent…
permissive · top 15,000 on PyPI
hashringImplements consistent hashing in Python using…
permissive · top 15,000 on PyPI
dict-hashGenerates consistent hashes for Python…
permissive · top 15,000 on PyPI
siphashProvides a Python implementation of SipHash, a…
permissive · top 15,000 on PyPI
ImageHashImageHash computes perceptual fingerprints of…
permissive · top 5,000 on PyPI
uhashringuhashring implements consistent hashing in pure…
permissive · top 15,000 on PyPI
poochPooch downloads files from HTTP, FTP, and data…
permissive · top 5,000 on PyPI
bagitCreate, validate, and manage BagIt-style…
permissive · top 15,000 on PyPI