std.digest.sha
- Computes SHA1 and SHA2 hashes of arbitrary data. SHA hashes are 20 to 64 byte
- quantities (depending on the SHA algorithm) that are like a checksum or CRC,
- but are more robust. *
| Category | Functions |
|---|---|
| Template API | SHA1
|
| OOP API | SHA1Digest |
| Helpers | sha1Of |
- SHA2 comes in several different versions, all supported by this module:
- SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224 and SHA-512/256.
- This module conforms to the APIs defined in
std.digest. To understand the - differences between the template and the OOP API, see
std.digest. - This module publicly imports
std.digestand can be used as a stand-alone - module.
License
alias SHA1 SHA1Digest SHA224 SHA224Digest SHA256 SHA256Digest SHA384 SHA384Digest SHA512 SHA512_224 SHA512_224Digest SHA512_256 SHA512_256Digest SHA512Digest
struct SHA
Types 15
structSHA(uint hashBlockSize, uint digestSize)
Template API SHA1/SHA2 implementation. Supports: SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224 and SHA-512/256.
The hashBlockSize and digestSize are in bits. However, it's likely easier to simply use the convenience aliases: SHA1, SHA224, SHA256, SHA384, SHA512, SHA512_224 and SHA512_256.
See std.digest for differences between template and OOP API.
Fields
blockSizeulong[blockSize / 512] countubyte[blockSize / 8] bufferubyte[128] paddingMethods
T Ch(T)(T x, T y, T z)T Maj(T)(T x, T y, T z)uint Parity(uint x, uint y, uint z)uint BigSigma0(uint x)uint BigSigma1(uint x)uint SmSigma0(uint x)uint SmSigma1(uint x)ulong BigSigma0(ulong x)ulong BigSigma1(ulong x)ulong SmSigma0(ulong x)ulong SmSigma1(ulong x)void T_0_15(int i, const(ubyte[64]) * input, ref uint[16] W, uint A, ref uint B, uint C, uint D,
uint E, ref uint T) pure nothrow @nogcvoid T_16_19(int i, ref uint[16] W, uint A, ref uint B, uint C, uint D, uint E, ref uint T) pure nothrow @nogcvoid T_20_39(int i, ref uint[16] W, uint A, ref uint B, uint C, uint D, uint E,
ref uint T) pure nothrow @nogcvoid T_40_59(int i, ref uint[16] W, uint A, ref uint B, uint C, uint D, uint E,
ref uint T) pure nothrow @nogcvoid T_60_79(int i, ref uint[16] W, uint A, ref uint B, uint C, uint D, uint E,
ref uint T) pure nothrow @nogcvoid T_SHA2_0_15(Word)(int i, const(ubyte[blockSize / 8]) * input, ref Word[16] W,
Word A, Word B, Word C, ref Word D, Word E, Word F, Word G, ref Word H, Word K) pure nothrow @nogcvoid T_SHA2_16_79(Word)(int i, ref Word[16] W,
Word A, Word B, Word C, ref Word D, Word E, Word F, Word G, ref Word H, Word K) pure nothrow @nogcprivate
void transformSHA2(Word)(Word[8] * state, const(ubyte[blockSize / 8]) * block) pure nothrow @nogcvoid put(scope const(ubyte)[] input...) @trusted pure nothrow @nogcUse this to feed the digest with data. Also implements the isOutputRange interface for `ubyte` and `const(ubyte)[]`.ubyte[digestSize / 8] finish() @trusted pure nothrow @nogcReturns the finished SHA hash. This also calls start to reset the internal state.aliasSHA512_224 = SHA!(1024, 224)
SHA alias for SHA-512/224, hash is ubyte28
aliasSHA512_256 = SHA!(1024, 256)
SHA alias for SHA-512/256, hash is ubyte32
aliasSHA1Digest = WrapperDigest!SHA1
OOP API SHA1 and SHA2 implementations. See std.digest for differences between template and OOP API.
This is an alias for , see there for more information.WrapperDigest!SHA1
aliasSHA224Digest = WrapperDigest!SHA224
ditto
aliasSHA256Digest = WrapperDigest!SHA256
ditto
aliasSHA384Digest = WrapperDigest!SHA384
ditto
aliasSHA512Digest = WrapperDigest!SHA512
ditto
ditto
ditto