Macos – Which checksum-generating command line programs are native to macOS

checksumcommand linehashingmacos

[Migrated question from stackoverflow here, because they said it was off-topic.]

I'm looking for a list/an overview of the command-line programs native to macOS that let you calculate checksums.

I know of the following:

CRC-32: /usr/bin/crc32

MD2: /usr/bin/openssl dgst -md2 [Note: produces an unknown option '-md2' error on my system]

MD4: /usr/bin/openssl dgst -md4

MD5: /sbin/md5 or /usr/bin/openssl dgst -md5

MDC-2: /usr/bin/openssl dgst -mdc2

RIPEMD-160: /usr/bin/openssl dgst -ripemd160

SHA: /usr/bin/openssl dgst -sha

SHA-1: /usr/bin/shasum -a 1 or /usr/bin/openssl dgst -sha1

SHA-224: /usr/bin/shasum -a 224 or /usr/bin/openssl dgst -sha224

SHA-256: /usr/bin/shasum -a 256 or /usr/bin/openssl dgst -sha256

SHA-384: /usr/bin/shasum -a 384 or /usr/bin/openssl dgst -sha384

SHA-512: /usr/bin/shasum -a 512 or /usr/bin/openssl dgst -sha512

Note: According to the openssl man page BLAKE2B and BLAKE2S can also be calculated, but I haven't managed to do it on macOS, neither with the default /usr/bin/openssl nor with the homebrewed version /usr/local/bin/openssl.

Those are the ones I know. Any other native ways to calculate additional checksums from the command line, e.g. Adler-32, CRC-64, GOST, Whirlpool etc.?

I know you can always install programs like rhash into /usr/local/bin, but I'm trying to look at the native methods first. This can also include scripting your own functions using native libraries, like zlib for Adler-32.

Best Answer

Sha256 is the default algorithm of openssl. OpenSSL-1.1.0 has included blake2b and blake2s message digests algorithms. You can use this command to see the list of supported algorithms.

openssl list --digest-commands 

If you use latest openssl-1.1.0b ( 29th September,2016 ), you could get this:

blake2b512        blake2s256        gost              md4
md5               mdc2              rmd160            sha1
sha224            sha256            sha384            sha512

It means that, you can use blake2b or blake2s as usual.

openssl dgst -blake2b512 /path/to/file
openssl dgst -blake2s256 /path/to/file
Related Question