An instance of HMAC that can be fed data as desired, and finished to compute the final hash when done.
import std.digest.sha : SHA1; import std.string : representation; string data1 = "Hello, world", data2 = "Hola mundo"; auto digest = hmac!SHA1("My s3cR3T keY".representation) .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);
Constructs an HMAC digest with the specified secret.