Module: SmartCampus::Sign

Defined in:
lib/smart_campus/sign.rb,
lib/smart_campus/sign/sha1.rb

Defined Under Namespace

Classes: SHA1

Class Method Summary collapse

Class Method Details

.generate(token_opt = {}) ⇒ Object



8
9
10
11
12
# File 'lib/smart_campus/sign.rb', line 8

def self.generate(token_opt={})
  params = Utils.stringify_keys(token_opt)
  sort_str = params_to_string(params)
  SHA1.sign(sort_str)
end

.generate_str(token_opt = '') ⇒ Object



4
5
6
# File 'lib/smart_campus/sign.rb', line 4

def self.generate_str(token_opt='')
  SHA1.sign(token_opt)
end

.params_to_string(params) ⇒ Object



14
15
16
# File 'lib/smart_campus/sign.rb', line 14

def self.params_to_string(params)
  params.sort.map { |item| item.join('=') }.join('&')
end