Class: CBXSignatureMaker
- Inherits:
-
Object
- Object
- CBXSignatureMaker
- Defined in:
- lib/cbx/cbx_signature_maker.rb
Instance Method Summary collapse
-
#initialize(key, secret, passphrase) ⇒ CBXSignatureMaker
constructor
A new instance of CBXSignatureMaker.
- #signature(request_url = '', body = '', timestamp = nil, method = 'GET') ⇒ Object
Constructor Details
#initialize(key, secret, passphrase) ⇒ CBXSignatureMaker
Returns a new instance of CBXSignatureMaker.
2 3 4 5 6 |
# File 'lib/cbx/cbx_signature_maker.rb', line 2 def initialize(key, secret, passphrase) @key = key @secret = secret @passphrase = passphrase end |
Instance Method Details
#signature(request_url = '', body = '', timestamp = nil, method = 'GET') ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cbx/cbx_signature_maker.rb', line 8 def signature(request_url='', body='', =nil, method='GET') body = body.to_json if body.is_a?(Hash) = Time.now.to_i if ! what = "#{}#{method.upcase}#{request_url}#{body}"; # create a sha256 hmac with the secret secret = Base64.decode64(@secret) hash = OpenSSL::HMAC.digest('sha256', secret, what) Base64.strict_encode64(hash) end |