

[](https://deps.rs/repo/gitlab/kurdy/sha3sum)

[](https://gitlab.com/kurdy/sha3sum)
# sha3sum — Print or check SHA3 / Keccak digests
Command-line tool wrapping the [RustCrypto/hashes](https://github.com/RustCrypto/hashes) `sha3` crate.
Options and output format mirror the GNU `sha256sum` / `sha512sum` family.
One goal of this project is a **cross-platform**, **standalone** executable with no external system libraries required.
---
## Supported algorithms
| `224` / `sha3_224` | SHA3-224 |
| `256` / `sha3_256` | SHA3-256 |
| `384` / `sha3_384` | SHA3-384 |
| `512` / `sha3_512` | SHA3-512 |
| `Keccak224` | Keccak-224 |
| `Keccak256` | Keccak-256 |
| `Keccak256Full` | Keccak-256-full |
| `Keccak384` | Keccak-384 |
| `Keccak512` | Keccak-512 |
---
## Install
### From crates.io (recommended)
```sh
cargo install sha3sum
```
### Pre-built binaries
Binary packages for Linux (x86\_64, aarch64) and Windows (x86\_64) are available in the
[Package Registry](https://gitlab.com/kurdy/sha3sum/-/packages).
See the [Wiki](https://gitlab.com/kurdy/sha3sum/-/wikis/home) for installation instructions.
### From source
```sh
git clone https://gitlab.com/kurdy/sha3sum.git
cd sha3sum
cargo build --release
# binary is at target/release/sha3sum
```
### Optional shell aliases
For convenience, you can add shell aliases for common algorithms:
```sh
alias sha3_512sum="sha3sum -a 512"
alias sha3_384sum="sha3sum -a 384"
alias sha3_256sum="sha3sum -a 256"
alias sha3_224sum="sha3sum -a 224"
alias keccak_512sum="sha3sum -a keccak512"
alias keccak_384sum="sha3sum -a keccak384"
alias keccak_256sum="sha3sum -a keccak256"
alias keccak_256Fullsum="sha3sum -a keccak256full"
alias keccak_224sum="sha3sum -a keccak224"
```
This provides shortcuts like `sha3_256sum`, `keccak_512sum`, etc.
---
## Usage
```
sha3sum - compute and check SHA3 message digest.
Usage: sha3sum [OPTIONS] [FILES]...
Arguments:
[FILES]... Displays the check sum for the files
Options:
-a, --algorithm <ALGORITHM>
sha3 algorithm {224 256 384 512 Keccak224 Keccak256 Keccak256Full Keccak384 Keccak512}
-c, --check <CHECK>
read SHA3 sums and file path from a file and check them
-b, --binary
read using Binary mode (default)
--quiet
don't print OK for each successfully verified file
--status
don't output anything, status code shows success
--tag
create a BSD-style checksum
-t, --text
read using Text mode
-l, --license
Prints license information
-h, --help
Print help
-V, --version
Print version
```
### Examples
```sh
# Hash a single file with SHA3-256
sha3sum -a 256 file.bin
# Hash all files in a directory with Keccak-512
sha3sum -a Keccak512 ./data/
# Hash a text file in text mode (line-by-line, strips \r)
sha3sum -a 384 -t document.txt
# BSD-style output → SHA3_256 (file.bin) = abc123…
sha3sum -a 256 --tag file.bin
# Hash stdin
# Verify a check file (GNU format or BSD format)
sha3sum -c checksums.txt
# Verify silently — check exit code only
sha3sum -c checksums.txt --status && echo "all OK"
# Verify and suppress OK lines
sha3sum -c checksums.txt --quiet
```
### Output formats
| Binary (default) | `abc123… *./file.bin` |
| Text (`-t`) | `abc123… ./file.bin` |
| BSD tag (`--tag`) | `SHA3_256 (./file.bin) = abc123…` |
| Check result | `./file.bin Ok` / `./file.bin NOk` |
> **Note:** the separator between hash and filename is a **no-break space** (`U+00A0`),
> which prevents false splits when filenames contain regular spaces.
### Exit codes
| `0` | Success |
| `1` | Unused (reserved) |
| `2` | Wrong / missing parameters |
| `64` | File open / read error |
| `65` | Hash mismatch |
---
## Performance tuning
By default each file is read in **64 KB blocks**. Set `SHA3_BLOCK_SIZE` at **compile time**
to override (value is embedded in the binary):
```sh
SHA3_BLOCK_SIZE=131072 cargo build --release
```
Multiple files are hashed **in parallel** using one thread per logical CPU
(`std::thread::available_parallelism`).
---
## Development
### Requirements
- Rust ≥ 1.85 (MSRV — required for edition 2024)
### Run tests
```sh
cargo test
```
### Run benchmarks
Benchmarks use [Criterion](https://github.com/bheisler/criterion.rs) and produce
statistical reports with HTML output under `target/criterion/`.
```sh
# Full benchmark suite
cargo bench
# Single group (algorithms | read_strategy | read_mode | file_sizes)
cargo bench -- algorithms
```
| `algorithms` | All 9 SHA3/Keccak variants — 2 MB file, MB/s throughput |
| `read_strategy` | Block-loop vs `io::copy` — 10 MB file |
| `read_mode` | Binary vs text mode — 4 KB UTF-8 file |
| `file_sizes` | SHA3-256 scaling: 4 KB / 2 MB / 10 MB |
### Check-file format
Two formats are accepted by `-c`:
**GNU format** (produced by default):
```
<hash><NBSP>*<filename> # binary mode
<hash><NBSP><filename> # text mode
```
**BSD tag format** (produced by `--tag`):
```
<ALGORITHM><NBSP>(<filename>)<NBSP>=<NBSP><hash>
```
---
## Compare with openssl
machine: Ryzen AI 7 350 16 cores
### Single file 500MB
On a single file, `sha3sum` is marginally slower than `openssl` (1.699s vs 1.501s), both being in the same order of magnitude. `b2sum` however is in a completely different league at 367ms, roughly 4.5x faster than either SHA3-512 implementation. If cross-platform compatibility or multi-file parallelism are not a requirement, `b2sum` from GNU coreutils is the clear winner.
### Multiple files (500 files various size)
`sha3sum` distributes the processing of 500 files across multiple threads in parallel. Although SHA3-512 is computationally heavier than BLAKE2b, parallelism more than compensates:
| `b2sum` | BLAKE2b (fast) | single-thread | 41.2s |
| `openssl dgst -sha3-512` | SHA3-512 (heavy) | single-thread | 139.9s |
| `sha3sum -a 512` | SHA3-512 (heavy) | **multi-thread** | **37.2s** |
`sha3sum` is the fastest in wall-clock time not because of a better algorithm, but because it leverages all available CPU cores to process files simultaneously.
---
## Tested platforms
### Real machines
| Linux | x86\_64 |
| macOS | aarch64 |
### Cross-compiled (from Linux)
| aarch64-unknown-linux-gnu | Linux |
| x86\_64-pc-windows-gnu | Windows |
| x86\_64-unknown-linux-musl | Linux (static) |
| aarch64-unknown-linux-musl | Linux (static) |
| arm-unknown-linux-gnueabihf | Linux |
| armv7-unknown-linux-gnueabihf | Linux |
---
## License
GPL-3.0-or-later — see [LICENSE](LICENSE).
[Sources on GitLab](https://gitlab.com/kurdy/sha3sum.git)