Security

Directory Checksum – recursively hash directory contents

Directory Checksum is a command-line utility that recursively calculates checksums for the contents of a directory and can display results down to a user-selected depth. It gives a hierarchical view of what changed rather than returning only one opaque checksum for an entire tree.

The program was created primarily to investigate container image build-cache problems. When Docker, BuildKit, Buildah, or another OCI image builder unexpectedly rebuilds a layer containing COPY or ADD instructions, Directory Checksum can be run inside successive builds. Comparing its output helps identify the file or directory responsible for invalidating the cache, after filtering such as .dockerignore has already been applied.

Files are hashed from their binary content and filesystem metadata such as ownership or creation time is ignored. Directory hashes are derived from the names and checksums of their immediate children. Empty directories therefore participate in the result instead of being silently omitted. Symbolic links are not followed; their target paths are hashed instead.

Output identifies the checksum, object type, and path relative to the directory being scanned. The maximum printed depth can be adjusted to balance detail against output volume.

This is free and open source software.

Key Features

  • Recursively calculates checksums for files and directories.
  • Prints results to a configurable maximum directory depth.
  • Includes empty directories in the calculated hierarchy.
  • Uses SHA-1 checksums for files and directory entries.
  • Builds directory hashes from the names and checksums of immediate children.
  • Does not follow symbolic links and instead hashes their target paths.
  • Marks output entries as directories, files, or symbolic links.
  • Reports paths relative to the scanned directory.
  • Helps debug unexpected Docker, BuildKit, Buildah, and OCI image layer cache invalidation.

Website: github.com/MShekow/directory-checksum
Support:
Developer: Marius Shekow
License: MIT License

Directory Checksum is written in Go. Learn Go with our recommended free books and free tutorials.


Related Software

CLI Data Hashing Tools
xxHashNon-cryptographic hash algorithm
b3sumImplementation of the BLAKE3 hash function
RHashCalculate and verify magnet links and various message digests
md5sumCompute and check MD5 message digest; part of GNU Coreutils
cfvTest and create checksum files
JacksumWork with checksums, CRCs, and message digests
md5Generate / check MD5 message digest
digupUpdate md5sum or shasum digest files
cksumCompute and verify file checksums
HashratHash-generation utility
ddgstHashing and checksum utility
QCalcFileHashHash calculator
hashdirChecksum directories and files
Hash CalculatorCalculates around 50 cryptographic hashes of strings and files
danoHashdeep/md5tree for media files
sha3sumKeccak, SHA-3, SHAKE, and RawSHAKE checksum utilities
luhaSimple file checksum tool
filepackFile hashing and verification
b2sumCalculate BLAKE2 checksums
cksfvCreate and check sfv listings using CRC32 checksums
cksfv.rsReimplements the classic cksfv tool
hashdeepGenerate and verify file hashes
hashitGenerate file hashes quickly

Read our verdict in the software roundup.


Best Free and Open Source Software Explore our comprehensive directory of recommended free and open source software. Our carefully curated collection spans every major software category.

This directory is part of our ongoing series of informative articles for Linux enthusiasts. It features hundreds of detailed reviews, along with open source alternatives to proprietary solutions from major corporations such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk.

You’ll also find interesting projects to try, hardware coverage, free programming books and tutorials, and much more.

Discovered a useful open source Linux program that we haven’t covered yet? Let us know by completing this form.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted