An implementation of the SHA-2 cryptographic hash algorithms.
There are 6 standard algorithms specified in the SHA-2 standard:
Sha224, which is the 32-bitSha256algorithm with the result truncated to 224 bits.Sha256, which is the 32-bitSha256algorithm.Sha384, which is the 64-bitSha512algorithm with the result truncated to 384 bits.Sha512, which is the 64-bitSha512algorithm.Sha512Trunc224, which is the 64-bitSha512algorithm with the result truncated to 224 bits.Sha512Trunc256, which is the 64-bitSha512algorithm with the result truncated to 256 bits.
Algorithmically, there are only 2 core algorithms: Sha256 and Sha512.
All other algorithms are just applications of these with different initial
hash values, and truncated to different digest bit lengths.
Usage
An example of using Sha256 is:
use ;
// create a Sha256 object
let mut hasher = default;
// write input message
hasher.input;
// read hash digest and consume hasher
let output = hasher.result;
assert_eq!;
An example of using Sha512 is:
use ;
// create a Sha512 object
let mut hasher = default;
// write input message
hasher.input;
// read hash digest and consume hasher
let output = hasher.result;
assert_eq!;