module AWS::Core::Signers::Base

@api private

Public Class Methods

hmac(key, value, digest = 'sha256') click to toggle source

Computes an HMAC digest of the passed string. @param [String] key @param [String] value @param [String] digest ('sha256') @return [String]

# File lib/aws/core/signers/base.rb, line 38
def hmac key, value, digest = 'sha256'
  OpenSSL::HMAC.digest(OpenSSL::Digest.new(digest), key, value)
end
sign(secret, string_to_sign, digest_method = 'sha256') click to toggle source

Signs a string using the credentials stored in memory. @param [String] secret Usually an AWS secret access key. @param [String] string_to_sign The string to sign. @param [String] digest_method The digest method to use when

computing the HMAC digest.

@return [String] Returns the computed signature.

# File lib/aws/core/signers/base.rb, line 28
def sign secret, string_to_sign, digest_method = 'sha256'
  Base64.encode64(hmac(secret, string_to_sign, digest_method)).strip
end

Private Instance Methods

hmac(key, value, digest = 'sha256') click to toggle source

Computes an HMAC digest of the passed string. @param [String] key @param [String] value @param [String] digest ('sha256') @return [String]

# File lib/aws/core/signers/base.rb, line 38
def hmac key, value, digest = 'sha256'
  OpenSSL::HMAC.digest(OpenSSL::Digest.new(digest), key, value)
end
sign(secret, string_to_sign, digest_method = 'sha256') click to toggle source

Signs a string using the credentials stored in memory. @param [String] secret Usually an AWS secret access key. @param [String] string_to_sign The string to sign. @param [String] digest_method The digest method to use when

computing the HMAC digest.

@return [String] Returns the computed signature.

# File lib/aws/core/signers/base.rb, line 28
def sign secret, string_to_sign, digest_method = 'sha256'
  Base64.encode64(hmac(secret, string_to_sign, digest_method)).strip
end