The OpenD Programming Language

HMAC.start

Reinitializes the digest, making it ready for reuse.

Note: The constructor leaves the digest in an initialized state, so that this method only needs to be called if an unfinished digest is to be reused.

struct HMAC(H, size_t hashBlockSize)
ref return
HMAC!(H, blockSize)
start
()
if (
hashBlockSize % 8 == 0
)

Return Value

Type: HMAC!(H, blockSize)

A reference to the digest for convenient chaining.

Examples

import std.digest.sha : SHA1;
import std.string : representation;
string data1 = "Hello, world", data2 = "Hola mundo";
auto hmac = HMAC!SHA1("My s3cR3T keY".representation);
hmac.put(data1.representation);
hmac.start();                   // reset digest
hmac.put(data2.representation); // start over
static immutable expected = [
    122, 151, 232, 240, 249, 80,
    19, 178, 186, 77, 110, 23, 208,
    52, 11, 88, 34, 151, 192, 255];
assert(hmac.finish() == expected);

Meta