| 1 |
# RustCrypto: SHA-3 |
| 2 |
|
| 3 |
[![crate][crate-image]][crate-link] |
| 4 |
[![Docs][docs-image]][docs-link] |
| 5 |
![Apache2/MIT licensed][license-image] |
| 6 |
![Rust Version][rustc-image] |
| 7 |
[![Project Chat][chat-image]][chat-link] |
| 8 |
[![Build Status][build-image]][build-link] |
| 9 |
|
| 10 |
Implementation of the [SHA-3] family of cryptographic hash algorithms. |
| 11 |
|
| 12 |
There are 4 standard fixed-size algorithms specified in the SHA-3 standard: |
| 13 |
`SHA3-224`, `SHA3-256`, `SHA3-384`, `SHA3-512`. |
| 14 |
|
| 15 |
`SHAKE128` and `SHAKE256` extendable output functions (XOF) are defined in the [`shake`] crate |
| 16 |
|
| 17 |
Additionally, this crate supports: |
| 18 |
- `Keccak224`, `Keccak256`, `Keccak384`, `Keccak512`: NIST submission without padding changes |
| 19 |
- `Keccak256Full`: CryptoNight variant of SHA-3 |
| 20 |
|
| 21 |
## Examples |
| 22 |
|
| 23 |
Output size of SHA3-256 is fixed, so its functionality is usually |
| 24 |
accessed via the `Digest` trait: |
| 25 |
|
| 26 |
```rust |
| 27 |
use hex_literal::hex; |
| 28 |
use sha3::{Digest, Sha3_256}; |
| 29 |
|
| 30 |
let mut hasher = Sha3_256::new(); |
| 31 |
hasher.update(b"abc"); |
| 32 |
let hash = hasher.finalize(); |
| 33 |
|
| 34 |
assert_eq!(hash, hex!("3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532")); |
| 35 |
``` |
| 36 |
|
| 37 |
See the [`digest`] crate docs for additional examples. |
| 38 |
|
| 39 |
## License |
| 40 |
|
| 41 |
The crate is licensed under either of: |
| 42 |
|
| 43 |
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) |
| 44 |
* [MIT license](http://opensource.org/licenses/MIT) |
| 45 |
|
| 46 |
at your option. |
| 47 |
|
| 48 |
### Contribution |
| 49 |
|
| 50 |
Unless you explicitly state otherwise, any contribution intentionally submitted |
| 51 |
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be |
| 52 |
dual licensed as above, without any additional terms or conditions. |
| 53 |
|
| 54 |
[//]: # (badges) |
| 55 |
|
| 56 |
[crate-image]: https://img.shields.io/crates/v/sha3.svg |
| 57 |
[crate-link]: https://crates.io/crates/sha3 |
| 58 |
[docs-image]: https://docs.rs/sha3/badge.svg |
| 59 |
[docs-link]: https://docs.rs/sha3/ |
| 60 |
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg |
| 61 |
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg |
| 62 |
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg |
| 63 |
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260041-hashes |
| 64 |
[build-image]: https://github.com/RustCrypto/hashes/actions/workflows/sha3.yml/badge.svg?branch=master |
| 65 |
[build-link]: https://github.com/RustCrypto/hashes/actions/workflows/sha3.yml?query=branch:master |
| 66 |
|
| 67 |
[//]: # (general links) |
| 68 |
|
| 69 |
[SHA-3]: https://en.wikipedia.org/wiki/SHA-3 |
| 70 |
[`shake`]: http://docs.rs/shake |
| 71 |
[`digest`]: https://docs.rs/digest |