The OpenD Programming Language

HMAC.put

Feeds a piece of data into the hash computation. This method allows the type to be used as an std.range.OutputRange.

struct HMAC(H, size_t hashBlockSize)
ref return
HMAC!(H, blockSize)
put
(
in ubyte[] data...
)
if (
hashBlockSize % 8 == 0
)

Return Value

Type: HMAC!(H, blockSize)

A reference to the digest for convenient chaining.

Examples

import std.digest.hmac, std.digest.sha;
import std.string : representation;
string data1 = "Hello, world", data2 = "Hola mundo";
auto hmac = HMAC!SHA1("My s3cR3T keY".representation);
hmac.put(data1.representation)
    .put(data2.representation);
static immutable expected = [
    197, 57, 52, 3, 13, 194, 13,
    36, 117, 228, 8, 11, 111, 51,
    165, 3, 123, 31, 251, 113];
assert(hmac.finish() == expected);

Meta