Class: RongCloud::Signer

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

Class Method Summary collapse

Class Method Details

.generate(params) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/rongcloud/signer.rb', line 3

def self.generate(params)
  app_secret = params.fetch(:app_secret)
  nonce = params.fetch(:nonce)
  timestamp = params.fetch(:timestamp)
  string = "#{app_secret}#{nonce}#{timestamp}"
  Digest::SHA1.hexdigest(string)
end

.verify?(params) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/rongcloud/signer.rb', line 11

def self.verify?(params)
  params.fetch(:signature) == generate(params)
end