Crate sm3

source ·
Expand description

An implementation of the SM3 cryptographic hash function defined in OSCCA GM/T 0004-2012.

Usage

Hasher functionality is expressed via traits defined in the digest crate.

use hex_literal::hex;
use sm3::{Digest, Sm3};

// create a hasher object, to use it do not forget to import `Digest` trait
let mut hasher = Sm3::new();

// write input message
hasher.update(b"hello world");

// read hash digest and consume hasher
let result = hasher.finalize();

assert_eq!(result[..], hex!("
    44f0061e69fa6fdfc290c494654a05dc0c053da7e5c52b84ef93a9d67d3fff88
")[..]);

Also see RustCrypto/hashes readme.

Re-exports

Structs

Traits

  • Convenience wrapper trait covering functionality of cryptographic hash functions with fixed output size.

Type Definitions

  • Sm3 hasher state.