hmac - the keyed hash of RFC 2104, over SHA-256.
hmac = import("crypto/hmac")tag = hmac.Hex(key, "the message")
if !hmac.Equal(tag, expected) { ... }A signature is checked with Equal rather than with ==, which stops as soon as two bytes differ and so says something about the key by how long it took.
¶Sum = fn(key, msg)source
Sum returns the 32 bytes signing msg with key.
¶Hex = fn(key, msg)source
Hex returns the signature of msg as hexadecimal digits.
¶Equal = fn(a, b)source
Equal reports whether two signatures are the same, taking the same time whether they differ in the first byte or in the last.