Expand description
Hash functions.
use bssl_crypto::digest;
// One-shot hashing.
let digest: [u8; 32] = digest::Sha256::hash(b"hello");
// Incremental hashing.
let mut ctx = digest::Sha256::new();
ctx.update(b"hel");
ctx.update(b"lo");
let digest2: [u8; 32] = ctx.digest();
assert_eq!(digest, digest2);
// Hashing with dynamic dispatch.
#[cfg(feature = "std")]
{
fn update_hash(ctx: &mut dyn std::io::Write) {
ctx.write(b"hel");
ctx.write(b"lo");
}
let mut ctx = digest::Sha256::new();
update_hash(&mut ctx);
assert_eq!(ctx.digest(), digest);
}Structs§
- Insecure
Sha1 - The insecure SHA-1 hash algorithm.
- Sha256
- The SHA-256 hash algorithm.
- Sha384
- The SHA-384 hash algorithm.
- Sha512
- The SHA-512 hash algorithm.
- Sha512_
256 - The SHA-512/256 hash algorithm.
Traits§
- Algorithm
- Provides the ability to hash in an algorithm-agnostic manner.