Class: HttpSignatures::Algorithm::Hmac
- Inherits:
-
Object
- Object
- HttpSignatures::Algorithm::Hmac
- Defined in:
- lib/http_signatures/algorithm/hmac.rb
Instance Method Summary collapse
-
#initialize(digest_name) ⇒ Hmac
constructor
A new instance of Hmac.
- #name ⇒ Object
- #sign(key, data) ⇒ Object
Constructor Details
#initialize(digest_name) ⇒ Hmac
Returns a new instance of Hmac.
7 8 9 10 |
# File 'lib/http_signatures/algorithm/hmac.rb', line 7 def initialize(digest_name) @digest_name = digest_name @digest = OpenSSL::Digest.new(digest_name) end |
Instance Method Details
#name ⇒ Object
12 13 14 |
# File 'lib/http_signatures/algorithm/hmac.rb', line 12 def name "hmac-#{@digest_name}" end |
#sign(key, data) ⇒ Object
16 17 18 |
# File 'lib/http_signatures/algorithm/hmac.rb', line 16 def sign(key, data) OpenSSL::HMAC.digest(@digest, key, data) end |