Import std.crypto.derive
Hmac
struct
Public Struct Hmac
HMAC (RFC 2104) of data with key, of any length: a MAC as long as its hash, which only who has the key can make. Check one with ConstantTimeEquals.
Examples
Local message = "The quick brown fox jumps over the lazy dog"
Local mac = Hmac.Sha256("key".Bytes, message)
Expect(Hex.Encode(mac) == "f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8")
// A MAC that came with a message is checked without telling where they differ.
Expect(ConstantTimeEquals(mac, Hmac.Sha256("key".Bytes, message)))-
HMAC-SHA1's 20 bytes, for the formats that ask for it.
-
HMAC-SHA1 of
text's UTF-8 bytes withkey. -
HMAC-SHA256's 32 bytes.
-
HMAC-SHA256 of
text's UTF-8 bytes withkey. -
HMAC-SHA512's 64 bytes.
-
HMAC-SHA512 of
text's UTF-8 bytes withkey.
Report an issue with this page or with FutureBlitz on GitHub.