MongooseA living laboratory of myriad worlds.

All help topics · Link to this topic

Showing help on 'binary_hmac()'

Syntax: string_hmac (STR text, STR key [, STR algo [, binary]])
binary_hmac (STR bin-string, STR key [, STR algo [, binary]])

Returns a string encoding the result of applying the HMAC-SHA256 cryptographically secure HMAC function to the contents of the string text or the binary string bin-string with the specified secret key. If algo is provided, it specifies the hashing algorithm to use. Currently, only "SHA1" and "SHA256" are supported. If binary is provided and true, the result is in MOO binary string format; by default the result is a hexidecimal string.

All cryptographically secure HMACs have the property that, if string_hmac(x, a) == string_hmac(y, b) then, almost certainly, equal(x, y) and furthermore, equal(a, b)

This can be useful, for example, in applications that need to verify both the integrity of the message (the text) and the authenticity of the sender (as demonstrated by the possession of the secret key).