Class: Mushikago::Auth::Signer
- Inherits:
-
Object
- Object
- Mushikago::Auth::Signer
- Defined in:
- lib/mushikago/auth/signer.rb
Overview
署名を作成するクラス
Instance Attribute Summary (collapse)
-
- (String) secret_key
readonly
シークレットキー.
Instance Method Summary (collapse)
-
- (Signer) initialize(secret_key)
constructor
A new instance of Signer.
-
- (String) sign(string_to_sign, digest_method = 'sha256')
署名.
Constructor Details
- (Signer) initialize(secret_key)
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
- (String) secret_key (readonly)
シークレットキー
10 11 12 |
# File 'lib/mushikago/auth/signer.rb', line 10 def secret_key @secret_key end |
Instance Method Details
- (String) sign(string_to_sign, digest_method = 'sha256')
署名
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 |