Skip to content

class OpenSSL::HMAC
inherits Reference

Allows computing Hash-based Message Authentication Code (HMAC).

It is a type of message authentication code (MAC) involving a hash function in combination with a key.

HMAC can be used to verify the integrity of a message as well as the authenticity.

See also RFC2104.

Class methods

.digest(algorithm : OpenSSL::Algorithm, key, data) : Bytes

Returns the HMAC digest of data using the secret key.

It may contain non-ASCII bytes, including NUL bytes.

algorithm specifies which OpenSSL::Algorithm is to be used.

View source

.hexdigest(algorithm : OpenSSL::Algorithm, key, data) : String

Returns the HMAC digest of data using the secret key, formatted as a hexadecimal string. This is necessary to safely transfer the digest where binary messages are not allowed.

See also #digest.

View source