Module: Simplepay::Authentication

Defined in:
lib/simplepay/authentication.rb

Overview

This module generates RFC-2104-compliant HMAC signatures. These signatures are used by both Amazon and you to determine whether or not data transmitted is authentic. The hash is based on the amazon secret access key, which is a trusted secret between both parties.

HMAC (RFC-2104 Specification)

For more information about the RFC-2104 spec, see www.ietf.org/rfc/rfc2104.txt

Class Method Summary collapse

Class Method Details

.authentic?(hash_data, signature, secret_access_key = Simplepay.aws_secret_access_key) ⇒ Boolean

Returns:



25
26
27
# File 'lib/simplepay/authentication.rb', line 25

def authentic?(hash_data, signature, secret_access_key = Simplepay.aws_secret_access_key)
  signature == generate(hash_data, secret_access_key)
end

.generate(hash_data, secret_access_key = Simplepay.aws_secret_access_key) ⇒ Object



21
22
23
# File 'lib/simplepay/authentication.rb', line 21

def generate(hash_data, secret_access_key = Simplepay.aws_secret_access_key)
  encode(digest(convert_to_string(hash_data), secret_access_key))
end