sha3sum 1.3.2

sha3sum - compute and check SHA3 message digest.
Documentation

Licence Version dependency status Download.io pipeline

sha3sum — Print or check SHA3 / Keccak digests

Command-line tool wrapping the 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

Flag value Algorithm
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)

cargo install sha3sum

Pre-built binaries

Binary packages for Linux (x86_64, aarch64) and Windows (x86_64) are available in the Package Registry.
See the Wiki for installation instructions.

From source

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:

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

# 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
echo -n "hello" | sha3sum -a 256

# 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

Mode Example
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

Code Meaning
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):

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

cargo test

Run benchmarks

Benchmarks use Criterion and produce statistical reports with HTML output under target/criterion/.

# Full benchmark suite
cargo bench

# Single group  (algorithms | read_strategy | read_mode | file_sizes)
cargo bench -- algorithms
Group What it measures
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:

Command Algorithm Model real
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

OS Architecture
Linux x86_64
macOS aarch64

Cross-compiled (from Linux)

Target OS
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.

Sources on GitLab