W3cubDocs

/Crystal 0.31

class OpenSSL::HMAC

Overview

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.

Defined in:

openssl/hmac.cr

Class Method Summary

Class Method Detail

def self.digest(algorithm : OpenSSL::Algorithm, key, data) : BytesSource

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.

def self.hexdigest(algorithm : OpenSSL::Algorithm, key, data) : StringSource

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.

© 2012–2019 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.31.1/OpenSSL/HMAC.html