Class: Signature

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

Overview

Creates signature of request parameters.

https://dev.twitter.com/oauth/overview/creating-signatures

Instance Method Summary collapse

Constructor Details

#initialize(oauth_token, oauth_secret, request_verb, request_path, request_params, nonce, epochtime) ⇒ Signature

Returns a new instance of Signature.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/signature.rb', line 14

def initialize(oauth_token, oauth_secret, request_verb, request_path, request_params, nonce, epochtime)
  @oauth_token = oauth_token
  @oauth_secret = oauth_secret

  @request_verb = request_verb
  @request_path = request_path
  @request_params = request_params

  @nonce = nonce
  @epochtime = epochtime
end

Instance Method Details

#digestObject



26
27
28
29
30
# File 'lib/signature.rb', line 26

def digest
  request_digest = OpenSSL::HMAC.hexdigest('sha1', signing_key, signing_base)

  Base64.encode64(Array(request_digest).pack('H*')).chomp
end