Skip to main content

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

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hash_directory-2025.10.16.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hash_directory-2025.10.16-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file hash_directory-2025.10.16.tar.gz.

File metadata

  • Download URL: hash_directory-2025.10.16.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hash_directory-2025.10.16.tar.gz
Algorithm Hash digest
SHA256 7c8a89ea8f5c122e0c93270674fa9a1999ca8c8a97b3eb2021a0f5f6b71e78cf
MD5 6510f3c3cc72ab5ebdd0754618d32120
BLAKE2b-256 73fa840217fce0bb68d6fd63d8730f0c6cb09cbf6a7188990ffb2dbcb13de5d8

See more details on using hashes here.

File details

Details for the file hash_directory-2025.10.16-py3-none-any.whl.

File metadata

File hashes

Hashes for hash_directory-2025.10.16-py3-none-any.whl
Algorithm Hash digest
SHA256 21a22d62e9304e30a4a2b99cdcdcf9de5c4ad37f96dafba7664a5c8edebb53b3
MD5 1ec3447b741b713d049dc46913596c0d
BLAKE2b-256 498b5ac9c5c7eed2d337fecf2bc69b66944a988d909866a58852d050573703b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page