class EasyWeixin::Auth

Public Class Methods

new(app_token,timestamp,nonce,signature,echostr) click to toggle source
# File lib/easy_weixin/auth.rb, line 5
def initialize(app_token,timestamp,nonce,signature,echostr)
        @app_token = app_token
        @timestamp = timestamp
        @nonce = nonce
        @signature = signature
        @echostr = echostr
end

Public Instance Methods

check_valid() click to toggle source
# 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