Intro To 'b2sum' Command In Linux
2024-05-06 - By Robert Elder
I use the 'b2sum' command to compute the BLAKE 2 message digest of a file or stream:
b2sum data.txt
4bdd5725495be9111e8818bcc916c68658d42ddbb3d22743e88215a21d7a26c77666c2e69e61e0ed5dba881aefc8eda5006cadd09cf773e41f60db6988f3b19c data.txt
echo "Hello World!" | b2sum
4bdd5725495be9111e8818bcc916c68658d42ddbb3d22743e88215a21d7a26c77666c2e69e61e0ed5dba881aefc8eda5006cadd09cf773e41f60db6988f3b19c -
'b2sum' Versus 'sha512sum'
When I run the b2sum command on a file, I'll see a 512 bit checksum value:
b2sum document.zip
0eb93176609c37d7f65b048f7ef1daff8ca4abb3d87ba445742a2d956dce546c5c8be2d0eba268705e4cd93ef4374d17b4b9dbc41c7bb6aa5972ae2a327b667d document.zip
This checksum value looks similar to the one that's produced by the sha512sum command:
sha512sum document.zip
c2f61433a1538dc18fe02bf4fd5b2a643c9868185c75186e75967a898625babb85f909a37a09522ecbf0e6ed789ea57983570e718cb37659861dbc026ce262aa document.zip
However, while the 'sha512sum' command uses the 512 bit variant of the SHA2 hash function, the 'b2sum' command uses the 512 bit variant of the Blake 2b hash function, as described in Request for comment 7693.
Benefits Of BLAKE 2 Hash Function
The BLAKE 2b hash function was first announced in 2012 and is based on a similar algorithm from 2008 that was one of five finalists during the NIST hash function competition.
According to the 'blake2.net' web site: "BLAKE2 is a cryptographic hash function faster than MD5, SHA-1, SHA-2, and SHA-3, yet is at least as secure as the latest standard SHA-3.".
Other Flags Of 'b2sum' Command
The 'b2sum' command supports all of the same flags and features as the 'md5sum' or 'sha*sum' commands:
info b2sum
...
6.4 ‘b2sum’: Print or check BLAKE2 digests
==========================================
‘b2sum’ computes a 512-bit checksum for each specified FILE. The same
usage and options as the ‘md5sum’ command are supported. *Note md5sum
invocation::. In addition ‘b2sum’ supports the following options.
...
Specify Shorter Length Message Digests
Additionally, it also supports the '-l' flag for specifying shorter length message digests:
b2sum -l 128 document.zip
3cdb21858ea7ba59361c24fa216f5609 document.zip
b2sum -l 64 document.zip
df7d854cee2b6654 document.zip
b2sum -l 32 document.zip
2f0bb563 document.zip
b2sum -l 24 document.zip
b44135 document.zip
And that's why the 'b2sum' command is my favourite Linux command.
Intro To 'stty' Command In Linux
Published 2023-10-04 |
$1.00 CAD |
Intro To 'nproc' Command In Linux
Published 2023-07-15 |
Intro To 'comm' Command In Linux
Published 2023-09-06 |
How To Force The 'true' Command To Return 'false'
Published 2023-07-09 |
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21 |
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01 |
Intro To 'chroot' Command In Linux
Published 2023-06-23 |
Join My Mailing List Privacy Policy |
Why Bother Subscribing?
|