Module sha256

Available on crate feature dep_orion only.
Expand description

SHA256 as specified in the FIPS PUB 180-4.

§Parameters:

  • data: The data to be hashed.

§Errors:

An error will be returned if:

§Panics:

A panic will occur if:

  • More than 2*(2^32-1) bits of data are hashed.

§Security:

  • SHA256 is vulnerable to length extension attacks.

§Recommendation:

  • It is recommended to use BLAKE2b when possible.

§Example:

use orion::hazardous::hash::sha2::sha256::Sha256;

// Using the streaming interface
let mut state = Sha256::new();
state.update(b"Hello world")?;
let hash = state.finalize()?;

// Using the one-shot function
let hash_one_shot = Sha256::digest(b"Hello world")?;

assert_eq!(hash, hash_one_shot);

Structs§

Digest
A type to represent the Digest that SHA256 returns.
Sha256
SHA256 streaming state.

Constants§

SHA256_BLOCKSIZE
The blocksize for the hash function SHA256.
SHA256_OUTSIZE
The output size for the hash function SHA256.