The OpenD Programming Language

hmac

Overload of HMAC to be used if H doesn't provide information about its block size.

  1. auto hmac(const(ubyte)[] secret)
    template hmac(H, size_t blockSize)
    @safe
    hmac
    (
    scope const(ubyte)[] secret
    )
  2. DigestType!H hmac(T data, const(ubyte)[] secret)
  3. template hmac(H)

Members

Functions

hmac
auto hmac(const(ubyte)[] secret)

Constructs an HMAC digest with the specified secret.

hmac
DigestType!H hmac(T data, const(ubyte)[] secret)

Computes an HMAC digest over the given range of data with the specified secret.

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);
auto digest = hmac.put(data1.representation)
                  .put(data2.representation)
                  .finish();
static immutable expected = [
    197, 57, 52, 3, 13, 194, 13,
    36, 117, 228, 8, 11, 111, 51,
    165, 3, 123, 31, 251, 113];
assert(digest == expected);

Meta