hash-cli

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 1 Imported by: 0

README

hash-cli

A fast command-line utility for computing file hashes using multiple algorithms simultaneously.

Features

  • Multi-algorithm support – Calculate checksums using various hashing algorithms in a single pass
  • Batch processing – Hash multiple files and directories in one command
  • Recursive support – Use the -r flag to traverse directories recursively
  • Progress indicator – Visual progress bar for large files (>100 MB)
  • Efficient – Uses parallel multi-writer approach to compute multiple hashes without re-reading the file

Supported Algorithms

Algorithm Flag
Blake3 --blake3
CRC32 --crc32
MD5 --md5
SHA-256 --sha256
SHA-3 (224-bit) --sha3-224
SHA-3 (256-bit) --sha3-256
SHA-3 (384-bit) --sha3-384
SHA-3 (512-bit) --sha3-512
XXHash --xxhash

Note: MD5 and CRC32 are included for compatibility and fast checksums only — do not use them for cryptographic security.

Installation

Prerequisites:

  • Go 1.25 or newer
  • A supported OS (Windows, macOS, Linux)

Option 1 — Build from source (recommended during development):

git clone https://github.com/marinewater/hash-cli
cd hash-cli
go build -o hash-cli .

Option 2 — Install into your $GOBIN from the project folder:

cd hash-cli
go install ./...

This will place the hash-cli binary into your $GOBIN (usually $GOPATH/bin), which should be on your PATH.

Usage

hash-cli [flags] FILE [FILE ...]

Flags:

  • --blake3 Compute BLAKE3
  • --crc32 Compute CRC32
  • --md5 Compute MD5
  • --sha256 Compute SHA-256
  • --sha3-224 Compute SHA3-224
  • --sha3-256 Compute SHA3-256
  • --sha3-384 Compute SHA3-384
  • --sha3-512 Compute SHA3-512
  • --xxhash Compute XXHash
  • -r, --recursive Recursive directory traversal
  • -U, --uppercase Print hashes in uppercase hex

Notes:

  • You can pass multiple files or directories; each is processed in turn.
  • A progress bar is shown for files larger than 100 MiB.
  • Use the -r flag to process directories recursively.

Examples

  • Compute BLAKE3 and SHA-256 for a single file:
hash-cli --blake3 --sha256 ./test.txt
  • Compute multiple algorithms for multiple files, uppercase output:
hash-cli --md5 --sha3-256 --xxhash -U file1.bin file2.iso
  • Compute multiple algorithms for all files in a directory:
hash-cli --md5 --sha3-256 --xxhash -r ./data
  • Compute SHA256 from Stdin:
cat file1.bin | hash-cli --sha256

Output format

For each file, the tool prints a header with the file name and size, followed by a table of hash names and values (hex):

Hashes for test.txt (12.0 KiB):
Name    Hash
Blake3  9a03a7...
md5     098f6b...
sha256  a9489b...

When -U/--uppercase is used, the hex values are printed in uppercase.

How it works (performance)

Internally, hash-cli fans out the file stream to multiple hashers via a multi-writer, so the file data is read only once while multiple digests are computed in parallel. This significantly reduces I/O overhead when you need several algorithms at once.

Exit codes

  • 0 on success
  • Non-zero if a file cannot be opened or an error occurs during hashing

Development

  • Run tests:
go test ./...

Documentation

Overview

Package main provides the entry point for the hash-cli application.

Directories

Path Synopsis
Package cmd provides the command-line interface for hash-cli, implementing the root command and flag handling using Cobra.
Package cmd provides the command-line interface for hash-cli, implementing the root command and flag handling using Cobra.
Package hashers provides a unified interface for various cryptographic and non-cryptographic hash algorithms including Blake3, CRC32, MD5, SHA-256, SHA-3, and XXHash.
Package hashers provides a unified interface for various cryptographic and non-cryptographic hash algorithms including Blake3, CRC32, MD5, SHA-256, SHA-3, and XXHash.
Package multiwriter provides an io.Writer implementation that duplicates writes to multiple underlying writers in parallel.
Package multiwriter provides an io.Writer implementation that duplicates writes to multiple underlying writers in parallel.
Package root provides core functionality for computing cryptographic hashes of files and stdin.
Package root provides core functionality for computing cryptographic hashes of files and stdin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL