1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-08 19:06:02 +02:00
BLAKE3/b3sum
Jack O'Connor cb32f0bd14 replace the new file module with inherent methods on Hasher
New methods:
- update_reader
- update_mmap
- update_mmap_rayon

These are more discoverable, more convenient, and safer.

There are two problems I want to avoid by taking a `Path` instead of a
`File`. First, exposing `Mmap` objects to the caller is fundamentally
unsafe, and making `maybe_mmap_file` private avoids that issue. Second,
taking a `File` raises questions about whether memory mapped reads
should behave like regular file reads. (Should they respect the current
seek position? Should they update the seek position?) Taking a `Path`
from the caller and opening the `File` internally avoids these
questions.
2023-09-16 17:04:27 -07:00
..
src replace the new file module with inherent methods on Hasher 2023-09-16 17:04:27 -07:00
tests add b3sum --seek 2023-06-06 20:25:00 -07:00
.gitignore check in the Cargo.lock for b3sum 2021-12-18 15:27:57 -05:00
Cargo.lock replace the new file module with inherent methods on Hasher 2023-09-16 17:04:27 -07:00
Cargo.toml replace the new file module with inherent methods on Hasher 2023-09-16 17:04:27 -07:00
README.md version 1.4.0 2023-06-08 13:06:32 -07:00
what_does_check_do.md fix a typo in the check doc 2021-11-13 09:24:15 -05:00

b3sum

A command line utility for calculating BLAKE3 hashes, similar to Coreutils tools like b2sum or md5sum.

Usage: b3sum [OPTIONS] [FILE]...

Arguments:
  [FILE]...  Files to hash, or checkfiles to check

Options:
      --keyed                 Use the keyed mode, reading the 32-byte key from stdin
      --derive-key <CONTEXT>  Use the key derivation mode, with the given context string
  -l, --length <LEN>          The number of output bytes, before hex encoding [default: 32]
      --seek <SEEK>           The starting output byte offset, before hex encoding [default: 0]
      --num-threads <NUM>     The maximum number of threads to use
      --no-mmap               Disable memory mapping
      --no-names              Omit filenames in the output
      --raw                   Write raw output bytes to stdout, rather than hex
  -c, --check                 Read BLAKE3 sums from the [FILE]s and check them
      --quiet                 Skip printing OK for each checked file
  -h, --help                  Print help (see more with '--help')
  -V, --version               Print version

See also this document about how the --check flag works.

Example

Hash the file foo.txt:

b3sum foo.txt

Time hashing a gigabyte of data, to see how fast it is:

# Create a 1 GB file.
head -c 1000000000 /dev/zero > /tmp/bigfile
# Hash it with SHA-256.
time openssl sha256 /tmp/bigfile
# Hash it with BLAKE3.
time b3sum /tmp/bigfile

Installation

Prebuilt binaries are available for Linux, Windows, and macOS (requiring the unidentified developer workaround) on the releases page. If you've installed Rust and Cargo, you can also build b3sum yourself with:

cargo install b3sum

On Linux for example, Cargo will put the compiled binary in ~/.cargo/bin. You might want to add that directory to your $PATH, or rustup might have done it for you when you installed Cargo.

If you want to install directly from this directory, you can run cargo install --path .. Or you can just build with cargo build --release, which puts the binary at ./target/release/b3sum.