3

[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.

  • Probably not what you're looking for since you already list MD5 (so adding this as a comment rather than an answer): /sbin/md5 – hertitu Aug 10 '16 at 13:36
  • You're right, thank you. Added. Also added openssl alternatives to shasum – JayB Aug 10 '16 at 14:08
  • 1
    A belated welcome to Super User. Sorry you're getting bounced around the Stack Exchange, but your question may be considered off-topic here, too. This site focuses on how to solve a specific problem. Asking how to calculate a checksum has been asked and answered many times. However, asking what program you can use to do something, or building a list of alternatives, is off-topic (product recommendation or too broad). It's a great question, and certainly useful, but I'm not sure there's an on-topic way to ask for what you're looking for. – fixer1234 Sep 8 '16 at 17:58
  • OK, I might have a solution for you. Use a self-answered question, and make the answer community wiki. The question would be something like "How can I calculate checksums from the command line using a program native to MacOS?", and add that the purpose is to create a canonical reference. Make your list so far an answer, and make sure it includes a sample command for each, not just a list of programs. Add a sentence inviting others to contribute, and make it community wiki to encourage that. – fixer1234 Sep 8 '16 at 18:11
  • Nah, you do it. I don't have the time. – JayB Sep 9 '16 at 1:09
2

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
  • 1
    Nitpick: SHA256 is default for openssl dgst as of 1.1.0; before that it's MD5. – dave_thompson_085 Sep 29 '16 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.