Module: TopDMC::Resources::Utils

Included in:
Base
Defined in:
lib/topdmc/resources/utils.rb

Instance Method Summary collapse

Instance Method Details

#hmac_sha1_signature(key, signature_string) ⇒ Object



8
9
10
11
12
# File 'lib/topdmc/resources/utils.rb', line 8

def hmac_sha1_signature(key, signature_string)
  digest = OpenSSL::Digest::Digest.new( 'sha1' )
  hmac = OpenSSL::HMAC.digest( digest, key, signature_string  )
  Base64.encode64( hmac ).chomp.gsub( /\n/, '' )
end

#nonce ⇒ Object



14
15
16
# File 'lib/topdmc/resources/utils.rb', line 14

def nonce
  rand(10 ** 30).to_s.rjust(30,'0')
end