LinuxCommandLibrary

b2sum

Calculate or verify BLAKE2 checksums

TLDR

Calculate the BLAKE2 checksum for one or more files

$ b2sum [path/to/file1 path/to/file2 ...]
copy

Calculate and save the list of BLAKE2 checksums to a file
$ b2sum [path/to/file1 path/to/file2 ...] > [path/to/file.b2]
copy

Calculate a BLAKE2 checksum from stdin
$ [command] | b2sum
copy

Read a file of BLAKE2 checksums and filenames and verify all files have matching checksums
$ b2sum [[-c|--check]] [path/to/file.b2]
copy

Only show a message for missing files or when verification fails
$ b2sum [[-c|--check]] --quiet [path/to/file.b2]
copy

Only show a message when verification fails, ignoring missing files
$ b2sum --ignore-missing [[-c|--check]] --quiet [path/to/file.b2]
copy

Check a known BLAKE2 checksum of a file
$ echo [known_blake2_checksum_of_the_file] [path/to/file] | b2sum [[-c|--check]]
copy

SYNOPSIS

b2sum [OPTION]... [FILE]...

PARAMETERS

-b, --binary
    Read files in binary mode. This is often the default, but ensures consistent handling across platforms.

-t, --text
    Read files in text mode, where carriage returns are ignored for compatibility.

-c, --check
    Read BLAKE2b checksums from the specified FILEs and verify them. The input format is typically 'checksum filename'.

--tag
    Create a BSD-style checksum. This includes a label like "BLAKE2b (filename) = checksum".

-l, --length=BITS
    Set the digest length in bits. The value must be between 1 and 512. Default is 512 bits.

-q, --quiet
    Suppress messages about successful checks when using --check.

-s, --status
    Don't output anything; the exit status indicates success or failure.

DESCRIPTION

The b2sum command is a utility for computing and verifying
BLAKE2b cryptographic checksums (or message digests) of files or standard input.

Developed as a modern alternative to older hash functions like MD5 or SHA-1,
BLAKE2b offers a superior balance of speed and security. It is significantly faster
than SHA-3, often comparable to MD5 or SHA-1 in speed, while providing a
much higher level of cryptographic strength and collision resistance.

b2sum is commonly used to ensure data integrity and authenticity. By generating
a unique checksum for a file, users can later verify that the file has not
been altered or corrupted during transmission or storage. If a single bit
in the file changes, the resulting BLAKE2b checksum will be drastically different.
When used with the --check option, it can read a list of checksums
from a file and verify them against the actual files.

CAVEATS

1. One-Way Function: Cryptographic hash functions like BLAKE2b are designed to be one-way; it is computationally infeasible to reverse the hash to obtain the original data.
2. Collision Resistance: While BLAKE2b is highly resistant to collisions (two different inputs producing the same hash), no hash function is perfectly collision-free in theory. However, for practical purposes, BLAKE2b is considered extremely secure.
3. Digest Length: Using the --length option to produce a shorter digest (e.g., less than 512 bits) reduces the collision resistance and cryptographic strength of the hash. This should only be done if the specific application warrants a smaller digest and accepts the reduced security margin.

BLAKE2B VS. BLAKE2S

BLAKE2 is actually a family of two hash functions: BLAKE2b and BLAKE2s. b2sum specifically implements BLAKE2b, which is optimized for 64-bit platforms and produces digests up to 512 bits. BLAKE2s is optimized for 32-bit platforms and produces digests up to 256 bits. The "b" in b2sum signifies its use of the BLAKE2b algorithm, making it ideal for general-purpose high-security and high-speed hashing on modern systems.

HISTORY

The BLAKE2 hash function, upon which b2sum is based, was published in 2012 by A. Biryukov, D. Dinu, and J. M. S. Neves. It was designed to improve upon BLAKE and offer a compelling alternative to SHA-3 by focusing on speed and security. Its inclusion in GNU Coreutils, which provides fundamental command-line utilities for Linux and other Unix-like operating systems, followed its widespread adoption and recognition as a high-performance and secure cryptographic hash function. b2sum provides users with a modern, fast, and robust tool for data integrity verification, complementing the existing suite of *sum commands.

SEE ALSO

Copied to clipboard