Class: Binance::Authentication
- Inherits:
-
Object
- Object
- Binance::Authentication
- Defined in:
- lib/binance/authentication.rb
Overview
Authentication response to API key and signature
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
-
#private_key_pass_phrase ⇒ Object
Returns the value of attribute private_key_pass_phrase.
-
#secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
- #hmac_sign(data) ⇒ Object
-
#initialize(key, secret, private_key = nil, private_key_pass_phrase = nil) ⇒ Authentication
constructor
A new instance of Authentication.
- #provide_private_key? ⇒ Boolean
- #rsa_sign(data) ⇒ Object
Constructor Details
#initialize(key, secret, private_key = nil, private_key_pass_phrase = nil) ⇒ Authentication
Returns a new instance of Authentication.
11 12 13 14 15 16 |
# File 'lib/binance/authentication.rb', line 11 def initialize(key, secret, private_key = nil, private_key_pass_phrase = nil) @key = key @secret = secret @private_key = private_key @private_key_pass_phrase = private_key_pass_phrase end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
9 10 11 |
# File 'lib/binance/authentication.rb', line 9 def key @key end |
#private_key ⇒ Object
Returns the value of attribute private_key.
9 10 11 |
# File 'lib/binance/authentication.rb', line 9 def private_key @private_key end |
#private_key_pass_phrase ⇒ Object
Returns the value of attribute private_key_pass_phrase.
9 10 11 |
# File 'lib/binance/authentication.rb', line 9 def private_key_pass_phrase @private_key_pass_phrase end |
#secret ⇒ Object
Returns the value of attribute secret.
9 10 11 |
# File 'lib/binance/authentication.rb', line 9 def secret @secret end |
Instance Method Details
#hmac_sign(data) ⇒ Object
22 23 24 25 26 |
# File 'lib/binance/authentication.rb', line 22 def hmac_sign(data) OpenSSL::HMAC.hexdigest( OpenSSL::Digest.new('sha256'), secret, data ) end |
#provide_private_key? ⇒ Boolean
18 19 20 |
# File 'lib/binance/authentication.rb', line 18 def provide_private_key? private_key end |
#rsa_sign(data) ⇒ Object
28 29 30 31 |
# File 'lib/binance/authentication.rb', line 28 def rsa_sign(data) pkey = OpenSSL::PKey::RSA.new(private_key, private_key_pass_phrase) Base64.encode64(pkey.sign('SHA256', data)) end |