View source code
Display the source code in std/digest/hmac.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Module std.digest.hmac

This package implements the hash-based message authentication code (HMAC) algorithm as defined in RFC2104. See also the corresponding Wikipedia article.


Template API HMAC implementation.

This implements an HMAC over the digest H. If H doesn't provide information about the block size, it can be supplied explicitly using the second overload.

This type conforms to std.digest.isDigest.

Compute HMAC over an input string

import std.ascii : LetterCase;
import std.digest : toHexString;
import std.digest.sha : SHA1;
import std.string : representation;

auto secret = "secret".representation;
assert("The quick brown fox jumps over the lazy dog"
        .toHexString!(LetterCase.lower) == "198ea1ea04c435c1246b586a06d5cf11c3ffcda6");


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


hmac Convenience constructor for HMAC.


hmac hmac!(H,H.blockSize) Convenience constructor for HMAC.



Boost License 1.0.