KECCAK

Template API SHA-3/SHAKE implementation using the Keccak[1600,24] function.

It supports SHA-3 and SHAKE XOFs. Though, it is recommended to use the SHA3_224, SHA3_256, SHA3_384, SHA3_512, SHAKE128, and SHAKE256 template aliases.

Members

Functions

finish
ubyte[digestSizeBytes] finish()

Returns the finished hash. This also clears part of the state, leaving just the final digest.

put
void put(const(ubyte)[] input)

Feed the algorithm with data. Also implements the std.range.primitives.isOutputRange interface for ubyte and const(ubyte)[].

start
void start()

Initiate or reset the state of the instance.

Manifest constants

blockSize
enum blockSize;

Digest size in bits.

Unions

__anonymous
union __anonymous
Undocumented in source.

Parameters

digestSize

Digest size in bits.

shake

SHAKE XOF digest size in bits. Defaults to 0 for SHA-3.

Throws

No exceptions are thrown.

Examples

// Defines SHAKE-128/256 with Template API, OOP API, and helper function.
alias SHAKE128_256 = KECCAK!(128, 256);
alias SHAKE128_256Digest = WrapperDigest!SHAKE128_256;
auto shake128_256Of(T...)(T data) { return digest!(SHAKE128_256, T)(data); }

Meta