Class: Mushikago::Auth::Signer
- Inherits:
-
Object
- Object
- Mushikago::Auth::Signer
- Defined in:
- lib/mushikago/auth/signer.rb
Overview
署名を作成するクラス
Instance Attribute Summary collapse
-
#secret_key ⇒ String
readonly
シークレットキー.
Instance Method Summary collapse
-
#initialize(secret_key) ⇒ Signer
constructor
A new instance of Signer.
-
#sign(string_to_sign, digest_method = 'sha256') ⇒ String
署名.
Constructor Details
#initialize(secret_key) ⇒ Signer
Returns a new instance of Signer.
13 14 15 |
# File 'lib/mushikago/auth/signer.rb', line 13 def initialize secret_key @secret_key = secret_key end |
Instance Attribute Details
#secret_key ⇒ String (readonly)
Returns シークレットキー.
10 11 12 |
# File 'lib/mushikago/auth/signer.rb', line 10 def secret_key @secret_key end |
Instance Method Details
#sign(string_to_sign, digest_method = 'sha256') ⇒ String
Returns 署名.
20 21 22 23 24 25 26 27 28 |
# File 'lib/mushikago/auth/signer.rb', line 20 def sign(string_to_sign, digest_method='sha256') Base64.encode64( OpenSSL::HMAC.digest( OpenSSL::Digest::Digest.new(digest_method), secret_key, string_to_sign ) ).strip end |