Class: SimpleWx::Signaturer

Inherits:
Base
  • Object
show all
Defined in:
lib/simple_wx/signaturer.rb

Instance Attribute Summary

Attributes inherited from Base

#error, #raise_flag

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Signaturer

Usage

signer = SimpleWx::Signaturer.new timestamp: params, nonce: params if signer.sign params

render text: params[:echostr]

else

...

end



13
14
15
16
17
# File 'lib/simple_wx/signaturer.rb', line 13

def initialize options = {}
  @timestamp = options.fetch :timestamp
  @nonce     = options.fetch :nonce
  @token     = SimpleWx.weixin_config["token"] #TODO 没有就raise错误,用method_missing
end

Instance Method Details

#sign(signture) ⇒ Object



19
20
21
22
# File 'lib/simple_wx/signaturer.rb', line 19

def sign signture
  @sort_array = [@timestamp, @nonce, @token].sort
  signture == sha1_encrypt
end