19 releases (9 breaking)

0.10.2 Dec 4, 2024
0.10.1 Nov 5, 2024
0.9.0 Nov 4, 2024
0.7.0 Jul 26, 2024
0.2.1 Feb 9, 2020

#598 in Command line utilities

Download history 6/week @ 2024-08-22 13/week @ 2024-08-29 13/week @ 2024-09-05 3/week @ 2024-09-12 18/week @ 2024-09-19 26/week @ 2024-09-26 3/week @ 2024-10-03 2/week @ 2024-10-10 5/week @ 2024-10-17 173/week @ 2024-10-24 354/week @ 2024-10-31 101/week @ 2024-11-07 31/week @ 2024-11-14 34/week @ 2024-11-21 104/week @ 2024-11-28 123/week @ 2024-12-05

294 downloads per month
Used in 3 crates (via sprint)

MIT license

74KB
618 lines

About

File hash checker represents a minimal solution meeting the following requirements:

  • Calculate the BLAKE3, SHA256, and/or SHA512 hashes of one or more files in sequence (for loop, iterator) or parallel (threading, messaging, rayon parallel iterator)
  • Provide library API
  • Benchmarks via criterion
  • Minimal dependencies: blake3, sha2, anyhow, clap, rayon
  • Provide a CLI utiility:
    • Simpler and more straightforward usage than sha256sum, b3sum
    • Save the hash to an adjacent hash file (if it doesn't already exist) (.sha256, .sha512, .b3)
    • Compare the current hash to an adjacent hash file (if it exists)

Usage

$ fhc -h
File hash checker (BLAKE3, SHA256, SHA512)

Usage: fhc [OPTIONS] [FILES]...

Arguments:
  [FILES]...  File(s)

Options:
  -a <ALGORITHM>           Algorithm [default: blake3] [possible values: blake3,
                           sha256, sha512, blake3-sha256, blake3-sha512,
                           sha256-sha512, all]
  -p, --process <PROCESS>  Approach for processing multiple files [default:
                           rayon-par-iter] [possible values: rayon-par-iter,
                           sequential-for-loop, sequential-iter, threading,
                           messaging]
  -h, --help               Print help
  -V, --version            Print version
$ fhc -V
fhc 0.10.2

Example

  1. Run fhc against one or more files to calculate and print the SHA256 or BLAKE3 hash for each file to stdout and save in adjacent hash files.
  2. At any later point, run fhc against one or more files with adjacent hash files to re-calculate the hash for each file and report OK if the hashes match and FAILED if the hashes do not match.

Benchmark

Changelog

  • 0.1.0 (2020-02-03): Initial release
  • 0.2.1 (2020-02-09): Produce .sha256 files compatible w/ sha256sum -c
  • 0.2.2 (2020-11-18): Update sha2 crate version
  • 0.3.0 (2024-01-07): Modernize
  • 0.4.0 (2024-01-24): Rename sequential process option to sequentialforloop; add sequentialiter and rayonpariter process options; move most of process option logic from CLI to library via process option functions and the process option run method; add criterion benchmarks; fix changelog; update dependencies
    • 0.4.1 (2024-01-24): Fix readme
    • 0.4.2 (2024-01-24): Fix changelog
  • 0.5.0 (2024-01-24): Add blake3 and -a option
    • 0.5.1 (2024-01-24): Fix readme
    • 0.5.2 (2024-01-25): Fix doc
    • 0.5.3 (2024-01-25): Fix readme
  • 0.6.0 (2024-01-25): Change CLI defaults to -a blake3 and -p rayon-par-iter
  • 0.7.0 (2024-07-26): Print help if zero files; fix makefile; update dependencies
    • 0.7.1 (2024-08-16): Fix makefile; fix changelog; fix readme; update dependencies
  • 0.8.0 (2024-10-24): Add clap color; update dependencies
  • 0.9.0 (2024-11-04): BREAKING: prefix hashes with algorithm labels ("BLAKE3:", "SHA256:"); add Hash::Blake3Sha256 and Hash::All variants and enable running multiple hash algorithms while reading the file from disk just once; add cargo lock file; housekeeping; update dependencies
  • 0.10.0 (2024-11-05): Add SHA512
    • 0.10.1 (2024-11-05): Fix description
    • 0.10.2 (2024-12-04): Update dependencies; add commit target to makefile

Dependencies

~6–15MB
~224K SLoC