rhsum (Rheo Sum) is a single-file C++ utility for deterministic polynomial hashing of a file or directory tree treated as one continuous virtual byte stream.
The canonical build command for this project is:
g++ -O3 -std=c++20 -march=native -pthread rhsum.cpp -o rhsum.
├── .github/workflows/ci.yml
├── .gitignore
├── Makefile
├── README.md
├── install.ps1
├── install.sh
├── rhsum.cpp
├── scripts/build.py
├── scripts/run_tests.py
├── tests/test_constant_1mb_42.py
├── tests/test_directory_tree.py
├── tests/test_follow_symlink_cycle.py
├── tests/test_follow_symlink_name.py
├── tests/test_follow_symlinks.py
├── tests/test_invalid_cli_args.py
├── tests/test_invalid_threads_arg.py
├── tests/test_permission_denied.py
├── tests/test_single_symlink_input.py
├── tests/test_special_name_only.py
├── tests/testlib.py
├── uninstall.ps1
└── uninstall.sh
- C++20-capable environment
g++with C++20 supportpthreadfor the canonical Unix build
Linux and other POSIX platforms use an mmap fast path for file reads. Other platforms fall back to standard C++ file I/O.
Canonical:
g++ -O3 -std=c++20 -march=native -pthread rhsum.cpp -o rhsumConvenience wrapper:
makeCross-platform build wrapper:
python3 scripts/build.pyInstall into your user PATH:
make installInstall directly from GitHub with curl | bash:
curl -fsSL https://raw.githubusercontent.com/MikeMirzayanov/rhsum/main/install.sh | sudo bashUser-only install from the same script:
curl -fsSL https://raw.githubusercontent.com/MikeMirzayanov/rhsum/main/install.sh | bash -s -- --userRemove the Unix installation:
curl -fsSL https://raw.githubusercontent.com/MikeMirzayanov/rhsum/main/uninstall.sh | sudo bashUser-only Unix uninstall:
curl -fsSL https://raw.githubusercontent.com/MikeMirzayanov/rhsum/main/uninstall.sh | bash -s -- --userWindows PowerShell install:
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/MikeMirzayanov/rhsum/main/install.ps1))) -UserWindows system-wide install from an elevated PowerShell:
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/MikeMirzayanov/rhsum/main/install.ps1))) -SystemWindows PowerShell uninstall:
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/MikeMirzayanov/rhsum/main/uninstall.ps1))) -UserWindows system-wide uninstall from an elevated PowerShell:
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/MikeMirzayanov/rhsum/main/uninstall.ps1))) -SystemInstall system-wide for all users:
sudo make install-systemRun tests:
make testRun only the Valgrind pass:
make test-valgrindCross-platform test runner:
python3 scripts/run_tests.pyValgrind pass on Linux:
python3 scripts/run_tests.py --valgrind./rhsum [options] <file|dir>-T, --threads <N>: number of worker threads-L, --follow-symlinks: follow symbolic links-v: print execution statistics to stderr--help: show usage help
./rhsum rhsum.cpp
./rhsum .
./rhsum -T 8 -v .- Input paths are sorted lexicographically before composition to keep output deterministic.
- If the input is a single file,
rhsumhashes only the file bytes. - If the input is a directory,
rhsumalways traverses it recursively and hashes relative paths from the traversal root for both files and directories, plus file contents. - Filesystem entities that are neither regular files nor directories contribute only their relative names and type markers, not any payload bytes.
- Empty directories therefore affect the resulting hash.
- Symlink and FIFO tests auto-skip on platforms where those primitives are unavailable or restricted.
make testalso runs the suite under Valgrind when Valgrind is available; this catches many memory errors and leaks in covered paths, but it is not a formal proof that no memory bugs exist.- For a 1 MiB file filled with byte value
42, the direct-file hash isd97a894407600000. - The repository currently has no license file. Add one before publishing if reuse by others is intended.
make install copies rhsum to ~/.local/bin by default and appends that directory to ~/.profile and ~/.bashrc if needed. It affects new shell sessions; the current shell still needs export PATH="$HOME/.local/bin:$PATH" or a restart.
make install-system installs rhsum into /usr/local/bin and writes /etc/profile.d/rhsum-path.sh. This usually requires root and affects new login shells for all users.