Reputation: 4282
See the OpenSSL::HMAC documentation.
I am trying this:
require "openssl"
puts OpenSSL::HMAC.hexdigest(:sha256, "secret key", "data")
and I am getting this error:
undefined constant OpenSSL::HMAC
Other OpenSSL methods are working fine, like OpenSSL::Digest.new("SHA256")
.
What am I doing wrong?
Upvotes: 4
Views: 314
Reputation: 7326
With require "openssl"
you don't require hmac
. This works for me:
require "openssl/hmac"
puts OpenSSL::HMAC.hexdigest(:sha256, "secret key", "data")
Upvotes: 4