34

I have sha1sum or sha512sum on an average Linux distro.

But where is the sha3sum command that can generateSHA-3 commands?

Evan Carroll
  • 28,578
  • 45
  • 164
  • 290
pepite
  • 1,053
  • 3
  • 14
  • 32

7 Answers7

31

You can use OpenSSL to do this. Run openssl list -digest-algorithms to get a list of algorithms:

...
SHA3-224
SHA3-256
SHA3-384
SHA3-512
...

As you can see sha3-{224,256,384,512} is supported by OpenSSL 1.1.1 (11 Sep 2018) from Ubuntu 18.10. You can also run openssl interactively:

OpenSSL> help
...
Message Digest commands (see the `dgst' command for more details)
blake2b512        blake2s256        gost              md4               
md5               rmd160            sha1              sha224            
sha256            sha3-224          sha3-256          sha3-384          
sha3-512          sha384            sha512            sha512-224        
sha512-256        shake128          shake256          sm3

To checksum a file:

openssl dgst -sha3-512 /bin/echo
SHA3-512(/bin/echo)= c9a3baaa2aa3d667a4ff475d893b3e84eb588fb46adecd0af5f3cdd735be88c62e179f98dc8275955da4ee5ef1dc7968620686c6f7f63f5b80f10e43bc1f00fc

To checksum a string:

printf "foobar" | openssl dgst -sha3-512

You can change the output format with these options:

  • -c Print out the digest in two digit groups separated by colons
  • -r Output the digest in the "coreutils" format, including newlines
Cristian Ciupitu
  • 2,430
  • 1
  • 22
  • 29
Evan Carroll
  • 28,578
  • 45
  • 164
  • 290
20

There are a number of implementations, e.g. Mattias Andrée's sha3sum, or the Perl Digest-SHA3 module. In Debian, install libdigest-sha3-perl; in Fedora, install sha3sum; both of these will provide a sha3sum command based on the Perl module, which behaves in the same way as the binaries you're used to.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
10

RHash application could do it:

rhash --sha3-256 yourfile

More info: rhash -h

it will work on Linux, BSD and Windows

Kiwy
  • 9,415
  • 13
  • 49
  • 79
monday
  • 101
  • 1
  • 3
4

For what it's worth, Busybox has had code for it since 2013.

cov
  • 66
  • 2
  • 2
    But since the final SHA3 specification was not released by NIST until August 5 2015, Busybox's implementation must have been based on preliminary versions of the spec... and so Busybox [needed a fix in 2016 in order to conform to the final version of the SHA3 algorithm specification](https://git.busybox.net/busybox/commit/?id=71a090f1871f165ebf3c31f733b36aafca71a6b4). – telcoM Feb 24 '22 at 12:57
2

If you have openssl installed you should have the hashalot command which says :

   Supported values for HASHTYPE:
           ripemd160 rmd160 rmd160compat sha256 sha384 sha512

You can also use directly the sha384 command.

A recent enough version of OpenSSL (1.1.1 or later) has full SHA-3 support, openssl help will show:

Message Digest commands (see the `dgst' command for more details)
blake2b512        blake2s256        gost              md4
md5               mdc2              rmd160            sha1
sha224            sha256            sha3-224          sha3-256
sha3-384          sha3-512          sha384            sha512
sha512-224        sha512-256        shake128          shake256
sm3
Patrick Mevzek
  • 3,130
  • 2
  • 20
  • 30
2

If you're lazy like me and are used to md5sum, sha1sum, sha256sum:

Create the file /usr/local/bin/sha3256sum and make it executable with chmod +x sha3256sum.

#!/bin/bash
rhash --sha3-256 $1

Then you can run:

sha3256sum file
user3559338
  • 131
  • 2
2

Another alternative is sha3sum for Linux, BSD, Windows, Mac,.... All platforms supported by Rust.

For Rust users: cargo install sha3sum

Further details are available with a wiki.

Note: I am the author of this tool.