| 1 |
# RustCrypto: SM3 |
| 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 |
Pure Rust implementation of the [SM3] cryptographic hash function defined |
| 11 |
in OSCCA GM/T 0004-2012. |
| 12 |
|
| 13 |
## Examples |
| 14 |
|
| 15 |
```rust |
| 16 |
use sm3::{Digest, Sm3}; |
| 17 |
use hex_literal::hex; |
| 18 |
|
| 19 |
let mut hasher = Sm3::new(); |
| 20 |
hasher.update(b"hello world"); |
| 21 |
let hash = hasher.finalize(); |
| 22 |
|
| 23 |
assert_eq!(hash, hex!("44f0061e69fa6fdfc290c494654a05dc0c053da7e5c52b84ef93a9d67d3fff88")); |
| 24 |
``` |
| 25 |
|
| 26 |
See the [`digest`] crate docs for additional examples. |
| 27 |
|
| 28 |
## License |
| 29 |
|
| 30 |
The crate is licensed under either of: |
| 31 |
|
| 32 |
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) |
| 33 |
* [MIT license](http://opensource.org/licenses/MIT) |
| 34 |
|
| 35 |
at your option. |
| 36 |
|
| 37 |
### Contribution |
| 38 |
|
| 39 |
Unless you explicitly state otherwise, any contribution intentionally submitted |
| 40 |
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be |
| 41 |
dual licensed as above, without any additional terms or conditions. |
| 42 |
|
| 43 |
[//]: # (badges) |
| 44 |
|
| 45 |
[crate-image]: https://img.shields.io/crates/v/sm3.svg |
| 46 |
[crate-link]: https://crates.io/crates/sm3 |
| 47 |
[docs-image]: https://docs.rs/sm3/badge.svg |
| 48 |
[docs-link]: https://docs.rs/sm3/ |
| 49 |
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg |
| 50 |
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg |
| 51 |
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg |
| 52 |
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260041-hashes |
| 53 |
[build-image]: https://github.com/RustCrypto/hashes/actions/workflows/sm3.yml/badge.svg?branch=master |
| 54 |
[build-link]: https://github.com/RustCrypto/hashes/actions/workflows/sm3.yml?query=branch:master |
| 55 |
|
| 56 |
[//]: # (general links) |
| 57 |
|
| 58 |
[SM3]: https://en.wikipedia.org/wiki/SM3_(hash_function) |
| 59 |
[`digest`]: https://docs.rs/digest |