Hashdir is a dotnet (f# language) CLI tool to compute the hash or checksum of a directory. This is done recursively using the directories, files and their names within. This is useful for quickly comparing directories and also determining if anything in the filesystem has changed.
It is written in F# on .NET 8.
The tool supports many popular hashing algorithms such as blake3, md5, ripemd160, sha1, sha256, sha384, sha512, and xxhash3.
- Dev Build:
make buildcan be used to quickly make sure the app builds. - Run Tests:
make testcan be used to make sure the tests are passing. - Check changes/PR:
git diff maincan be used to understand the feature branch.
The solution is organized into several projects within the src/ directory.
-
src/App: The main CLI application project.Program.fs: The entry point of the application, responsible for parsing command-line arguments and orchestrating the hashing process.
-
src/HashUtil: A library project containing the core hashing logic.Checksum.fs: This is a key file. It defines the supported hash algorithms (HashTypediscriminated union), a function to parse the algorithm from user input (parseHashType), and a factory function to create the appropriateHashAlgorithminstance (getHashAlgorithm). When adding a new algorithm, this file is the primary one to modify.NonCryptoWrapper.fs: A wrapper class that adapts non-cryptographic hash algorithms (likeXxHash3) to the standardHashAlgorithminterface, allowing them to be used seamlessly with the existing hashing infrastructure.Hashing.fs: Contains the logic for hashing files and directories.Library.fs: Provides a programmatic API for the hashing functionality.Util.fs: Contains utility functions, includingcomputeHashOfString.
-
src/Checksums: A C# project that provides an implementation of theRIPEMD160algorithm. -
src/App.Tests: Contains tests for theAppproject. -
src/HashUtil.Tests: Contains tests for theHashUtillibrary.HashTests.fs: Contains tests for the hashing functionality, including tests for different algorithms and input strings. When adding a new algorithm, this file should be updated with new test cases.