Class: HmacSignature::Signature

Inherits:
Struct
  • Object
show all
Defined in:
lib/hmac_signature/signature.rb

Constant Summary collapse

VERSION =
"1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



4
5
6
# File 'lib/hmac_signature/signature.rb', line 4

def key
  @key
end

#methodObject

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



4
5
6
# File 'lib/hmac_signature/signature.rb', line 4

def method
  @method
end

#paramsObject

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



4
5
6
# File 'lib/hmac_signature/signature.rb', line 4

def params
  @params
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



4
5
6
# File 'lib/hmac_signature/signature.rb', line 4

def path
  @path
end

#secretObject

Returns the value of attribute secret

Returns:

  • (Object)

    the current value of secret



4
5
6
# File 'lib/hmac_signature/signature.rb', line 4

def secret
  @secret
end

#timestampObject

Returns the value of attribute timestamp

Returns:

  • (Object)

    the current value of timestamp



4
5
6
# File 'lib/hmac_signature/signature.rb', line 4

def timestamp
  @timestamp
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



4
5
6
# File 'lib/hmac_signature/signature.rb', line 4

def version
  @version
end

Instance Method Details

#string_to_signObject



12
13
14
# File 'lib/hmac_signature/signature.rb', line 12

def string_to_sign
	[method, path, parameter_string].join("\n")
end

#to_sObject



7
8
9
10
# File 'lib/hmac_signature/signature.rb', line 7

def to_s
	digest = OpenSSL::Digest::SHA256.new
	OpenSSL::HMAC.hexdigest(digest, secret, string_to_sign)
end