Method: OpenSSL::HMAC.digest
- Defined in:
- lib/openssl/hmac.rb
.digest(digest, key, data) ⇒ Object
:call-seq:
HMAC.digest(digest, key, data) -> aString
Returns the authentication code as a binary string. The digest parameter specifies the digest algorithm to use. This may be a String representing the algorithm name or an instance of OpenSSL::Digest.
Example
key = 'key'
data = 'The quick brown fox jumps over the lazy dog'
hmac = OpenSSL::HMAC.digest('SHA1', key, data)
#=> "\xDE|\x9B\x85\xB8\xB7\x8A\xA6\xBC\x8Az6\xF7\n\x90p\x1C\x9D\xB4\xD9"
35 36 37 38 39 |
# File 'lib/openssl/hmac.rb', line 35 def digest(digest, key, data) hmac = new(key, digest) hmac << data hmac.digest end |