Class: EasyWeixin::Auth
- Inherits:
-
Object
- Object
- EasyWeixin::Auth
- Defined in:
- lib/easy_weixin/auth.rb
Instance Method Summary collapse
- #check_valid ⇒ Object
-
#initialize(app_token, timestamp, nonce, signature, echostr) ⇒ Auth
constructor
A new instance of Auth.
Constructor Details
#initialize(app_token, timestamp, nonce, signature, echostr) ⇒ Auth
Returns a new instance of Auth.
5 6 7 8 9 10 11 |
# File 'lib/easy_weixin/auth.rb', line 5 def initialize(app_token,,nonce,signature,echostr) @app_token = app_token @timestamp = @nonce = nonce @signature = signature @echostr = echostr end |
Instance Method Details
#check_valid ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/easy_weixin/auth.rb', line 13 def check_valid array = [@app_token, @timestamp, @nonce].sort secret_str = Digest::SHA1.hexdigest(array.join) if @signature == secret_str return @echostr else return false end end |