Class: XiWechatCorp::SHA1Signer

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

Overview

Sign and verify the signature

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ SHA1Signer

Returns a new instance of SHA1Signer.



4
5
6
# File 'lib/xi_wechat_corp/sha1_signer.rb', line 4

def initialize(token)
  @token = token
end

Instance Method Details

#sign(*args) ⇒ Object



8
9
10
11
12
# File 'lib/xi_wechat_corp/sha1_signer.rb', line 8

def sign(*args)
  sha1 = Digest::SHA1.new
  [@token, *(args.compact)].map(&:to_s).sort.each {|s| sha1 << s }
  sha1.hexdigest
end