#keccak-hash #xof #keccak #digest

no-std sha3

Implementation of the SHA-3 family of cryptographic hash algorithms

42 releases

Uses new Rust 2024

0.11.0 Apr 2, 2026
0.11.0-rc.9 Mar 18, 2026
0.11.0-rc.8 Feb 26, 2026
0.11.0-rc.3 Sep 3, 2025
0.3.0 Nov 17, 2016

#1425 in Cryptography

Download history 531874/week @ 2025-12-28 1006796/week @ 2026-01-04 1145228/week @ 2026-01-11 1268334/week @ 2026-01-18 1223333/week @ 2026-01-25 1300431/week @ 2026-02-01 1222367/week @ 2026-02-08 1202269/week @ 2026-02-15 1353661/week @ 2026-02-22 1602683/week @ 2026-03-01 1808980/week @ 2026-03-08 1493329/week @ 2026-03-15 1304724/week @ 2026-03-22 1356803/week @ 2026-03-29 1354692/week @ 2026-04-05 1451266/week @ 2026-04-12

5,573,440 downloads per month
Used in 10,083 crates (1,406 directly)

MIT/Apache

530KB
351 lines

RustCrypto: SHA-3

crate Docs Apache2/MIT licensed Rust Version Project Chat Build Status

Implementation of the SHA-3 family of cryptographic hash algorithms.

There are 6 standard algorithms specified in the SHA-3 standard:

  • SHA3-224, SHA3-256, SHA3-384, SHA3-512
  • SHAKE128 and SHAKE256 (an extendable output function (XOF))

Additionally, this crate supports:

  • KeccakFull: CryptoNight variant of SHA-3
  • Keccak224, Keccak256, Keccak384, Keccak512: NIST submission without padding changes

Examples

Output size of SHA3-256 is fixed, so its functionality is usually accessed via the Digest trait:

use hex_literal::hex;
use sha3::{Digest, Sha3_256};

let mut hasher = Sha3_256::new();
hasher.update(b"abc");
let hash = hasher.finalize();

assert_eq!(hash, hex!("3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532"));

SHAKE functions have an extendable output, so finalization method returns XOF reader from which results of arbitrary length can be read. Note that these functions do not implement Digest, so lower-level traits have to be imported:

use sha3::{Shake128, digest::{Update, ExtendableOutput, XofReader}};
use hex_literal::hex;

let mut hasher = Shake128::default();
hasher.update(b"abc");
let mut reader = hasher.finalize_xof();
let mut buf = [0u8; 10];
reader.read(&mut buf);
assert_eq!(buf, hex!("5881092dd818bf5cf8a3"));
reader.read(&mut buf);
assert_eq!(buf, hex!("ddb793fbcba74097d5c5"));

See the digest crate docs for additional examples.

License

The crate is licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies