ddn.crypto.hash.sha

SHA-1 and SHA-2 hash implementations.

This module provides SHA-1 (legacy) and SHA-2 (SHA-256, SHA-384, SHA-512) hash implementations. SHA-1 is deprecated and should not be used for security-critical purposes; SHA-256 and SHA-512 are recommended for all new code.

Types 9

SHA-1 secure hash algorithm (RFC 3174).

DEPRECATED — Do not use for security-critical purposes.

SHA-1 is no longer considered collision-resistant. NIST deprecated it in 2011, and practical collision attacks have been demonstrated since 2017 (SHAttered). SHA-1 must not be used for digital signatures, certificate generation, or any application that relies on collision resistance.

Acceptable legacy uses include HMAC construction (where collision resistance of the underlying hash is not required), non-security checksums, and compatibility with existing protocols that mandate SHA-1. Even in those cases, consider migrating to SHA-256 at the earliest opportunity.

See Also

SHA256Digest, SHA512Digest
Methods
void wipe() nothrow @nogc @trustedVolatile-wipes all mutable hash state.
Hash update(const(ubyte)[] input)
ubyte[] finish()
void reset()
size_t blockSize() @property const
size_t size() @property const
Constructors

SHA-256 implementation (FIPS 180-4).

Methods
void wipe() nothrow @nogc @trustedVolatile-wipes the chaining state, byte count, and partial block.
void reset()
Hash update(const(ubyte)[] input)
ubyte[] finish()
size_t blockSize() @property const
size_t size() @property const
Constructors

SHA-512 implementation (FIPS 180-4).

Methods
void wipe() nothrow @nogc @trustedVolatile-wipes the chaining state, byte count, and partial block.
void reset()
Hash update(const(ubyte)[] input)
ubyte[] finish()
size_t blockSize() @property const
size_t size() @property const
Constructors

SHA-384 implementation (FIPS 180-4).

SHA-384 uses the same algorithm as SHA-512 but with different initial values and the output is truncated to 48 bytes.

Methods
void wipe() nothrow @nogc @trustedVolatile-wipes all mutable hash state.
void reset()
Hash update(const(ubyte)[] input)
ubyte[] finish()
size_t blockSize() @property const
size_t size() @property const
Constructors
classSHA3Digest(int bits) : Hash

SHA-3 (Keccak) Digest Implementation.

Methods
void reset()
Hash update(const(ubyte)[] input)
ubyte[] finish()
size_t blockSize() @property const
size_t size() @property const
Constructors

SHA3-224

SHA3-256

SHA3-384

SHA3-512