A lightweight file integrity checker written in C++20 for Windows.
HashGuard uses SHA-256 hashing to detect changes in files and directories. It supports recursive directory scanning, JSON baselines, and file integrity verification through a simple command-line interface.
- SHA-256 hashing using Windows BCrypt
- Recursive directory scanning
- JSON baseline creation
- Detection of modified, added, and deleted files
- File integrity verification
- Command-line interface
- Execution time measurement
- Windows 10 or 11
- Visual Studio 2026 with C++ desktop development tools
- C++20
- Clone or download the repository.
- Open
HashGuard.slnxin Visual Studio 2026. - Select
Releaseandx64. - Build the solution.
- Find
HashGuard.exein the build output directory.
Open CMD in the directory containing HashGuard.exe.
Calculate the SHA-256 hash of a single file.
HashGuard.exe hash "C:\files\test.txt"Recursively scan a directory and display file hashes and sizes.
HashGuard.exe scan "C:\files"Create a JSON baseline containing file paths, sizes, and SHA-256 hashes.
HashGuard.exe init "C:\files"The baseline is saved as data.json in the parent directory of the scanned folder.
Compare the current directory contents against the saved baseline.
HashGuard.exe verify "C:\files"Possible results:
unchanged— File content has not changed.modified— File content has changed.added— A new file was detected.deleted— A previously recorded file is missing.
Display available commands.
HashGuard.exe helpmodified -> test.txt
added -> new.txt
verification completed
unchanged -> 0
modified -> 1
added -> 1
deleted -> 0
time -> 2.41 ms
Initial SHA-256 performance measurements using the Release x64 build:
| File size | Execution time |
|---|---|
| 10 MiB | 10.83 ms |
| 100 MiB | 102.93 ms |
These are single-run measurements on one machine, including file I/O and command overhead. Results may vary depending on hardware and filesystem caching.
- nlohmann/json — JSON parsing and serialization
- Windows BCrypt API — SHA-256 hashing
- A baseline must be created before running verification.
- The baseline file is stored outside the scanned directory.
- Existing baselines are not overwritten by the
initcommand. - Baselines are not cryptographically authenticated and should be protected from unauthorized changes.
- File paths containing non-ASCII characters may not work correctly in the current CLI version.
- The application currently returns exit code
0even when an error is reported.
This project is licensed under the MIT License.
