Skip to main content

Hash Directory

A command line program (and python library) for hashing directories. Can also do hash-based comparisons between directories (like diff -qr).

Command line usage

hash-directory some/path

This will return the sha-256 hash of some/path. For an explanation of how this is calculated go to hash_directory.

Hash overviews

hash-directory some/path -o

This generates a hash overview of this directory (or file). This is simply file path and hash, one per line, one line for each file within the directory tree.

This looks something like this:

. blablablathsiisahash
./foo blablablathsiisahash
./foo/bar.txt blablablathsiisahash

This can be used when comparing directories by storing the output to a file. Example code for Linux:

hash-directory some/path -o > some.hash

Comparing directories

hash-directory some/path -c another/path

This will compare the directories by first computing the hashes and then iterating of the directories to show the differences.

Now if you don't want to recalculate the hashes whenever comparing, then you can pass the output of overviews as a file, like this:

hash-directory some.hash -c another.hash
# or
hash-directory some.hash -c another/path

As Python library

Install it using pip install hash-directory.

And then import using import hash_directory

Basic usage

import hash_directory

hash_directory.hash_directory("some/path")

This will return the sha-256 hash of some/path. For an explanation of how this is calculated go to hash_directory.

hash_directory

Parameters:

  • path: The path to calculate the hash of
  • hash_function (default=hashlib.sha256): A hash function from hashlib

For files (yes, this program of course also works on files) this is equivalent to hashlib.file_digest("some/path", "sha256").hexdigest().

For directories on the other hand, we first take all files inside this directory and sort them by file name. Then for each file we update our running hash with the file name (encoded in utf-8) and then the file hash.

Other functions and classes

For now just a simple list:

  • compare_directories (function)
  • DirectoryHasher (class)

Metadata

Release files for hash-directory 2026.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hash-directory 2026.2.4
File Size Uploaded Provenance Actions
hash_directory-2026.2.4.tar.gz 5.2 kB Without provenance Details for hash_directory-2026.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hash-directory 2026.2.4
File Interpreter ABI Platform Actions
hash_directory-2026.2.4-py3-none-any.whl Python 3 none any Details for hash_directory-2026.2.4-py3-none-any.whl

Total release size: 12.1 kB

Release files / hash_directory-2026.2.4.tar.gz

Download URL hash_directory-2026.2.4.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1f0642b718283bc8ebcb37166cc47a7a80acfe9f3b2c1eef84ee58d4fa70f4df
BLAKE2b-256 checksum
How to use checksums
6eb16eb2cf36f276361a45aa19b988f4a6f22fd4c424c9e51e71470a85ebbc1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / hash_directory-2026.2.4-py3-none-any.whl

Download URL hash_directory-2026.2.4-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c27b239274d8e2be52443512fac139497a9322192933eceffb00dc68bfbdb4b8
BLAKE2b-256 checksum
How to use checksums
c7913a004cf28c35168be31f54cb66c11fb0f2012b89b31cfc4d1f748c8ddf80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for hash-directory 2026.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page