Expand description
Hash functions
§SHA-2 and SHA-3 hashing
Implements libsodium’s crypto_hash_sha256_*, crypto_hash_sha512_*,
crypto_hash_sha3256_*, and crypto_hash_sha3512_* functions.
SHA-2 and SHA-3 are unkeyed hash functions. They produce fixed-size digests
that identify input bytes, but they do not prove who created the input. Use
crate::classic::crypto_auth or the direct HMAC modules when a shared
secret key is required.
use dryoc::classic::crypto_hash::*;
let message = b"The empty vessel makes the loudest sound.";
let mut default_digest: Digest = [0u8; 64];
crypto_hash(&mut default_digest, message);
assert_eq!(default_digest.len(), 64);
let mut sha256 = Sha256Digest::default();
crypto_hash_sha256(&mut sha256, message);
assert_eq!(sha256.len(), 32);
let mut sha512: Sha512Digest = [0u8; 64];
crypto_hash_sha512(&mut sha512, message);
assert_eq!(sha512.len(), 64);
let mut sha3256 = Sha3256Digest::default();
crypto_hash_sha3256(&mut sha3256, message);
assert_eq!(sha3256.len(), 32);
let mut sha3512: Sha3512Digest = [0u8; 64];
crypto_hash_sha3512(&mut sha3512, message);
assert_eq!(sha3512.len(), 64);Structs§
- Sha256
State - Internal state for SHA-256 functions.
- Sha512
State - Internal state for SHA-512 functions.
- Sha3256
State - Internal state for SHA3-256 functions.
- Sha3512
State - Internal state for SHA3-512 functions.
Functions§
- crypto_
hash - Computes a SHA-512 hash from
inputusing libsodium’s defaultcrypto_hashprimitive. - crypto_
hash_ sha256 - Computes a SHA-256 hash from
input. - crypto_
hash_ sha512 - Computes a SHA-512 hash from
input. - crypto_
hash_ sha256_ final - Finalizes
stateof SHA-256, and writes the digest tooutputconsumingstate. - crypto_
hash_ sha256_ init - Initializes a SHA-256 hasher.
- crypto_
hash_ sha256_ update - Updates
stateof SHA-256 hasher withinput. - crypto_
hash_ sha512_ final - Finalizes
stateof SHA-512, and writes the digest tooutputconsumingstate. - crypto_
hash_ sha512_ init - Initializes a SHA-512 hasher.
- crypto_
hash_ sha512_ update - Updates
stateof SHA-512 hasher withinput. - crypto_
hash_ sha3256 - Computes a SHA3-256 hash from
input. - crypto_
hash_ sha3512 - Computes a SHA3-512 hash from
input. - crypto_
hash_ sha3256_ final - Finalizes
stateof SHA3-256, and writes the digest tooutputconsumingstate. - crypto_
hash_ sha3256_ init - Initializes a SHA3-256 hasher.
- crypto_
hash_ sha3256_ update - Updates
stateof SHA3-256 hasher withinput. - crypto_
hash_ sha3512_ final - Finalizes
stateof SHA3-512, and writes the digest tooutputconsumingstate. - crypto_
hash_ sha3512_ init - Initializes a SHA3-512 hasher.
- crypto_
hash_ sha3512_ update - Updates
stateof SHA3-512 hasher withinput.
Type Aliases§
- Digest
- Type alias for SHA512 digest output.
- Sha256
Digest - Type alias for SHA256 digest output.
- Sha512
Digest - Type alias for SHA512 digest output.
- Sha3256
Digest - Type alias for SHA3-256 digest output.
- Sha3512
Digest - Type alias for SHA3-512 digest output.