Class: EasyWeixin::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_weixin/auth.rb

Instance Method Summary collapse

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,timestamp,nonce,signature,echostr)
	@app_token = app_token
	@timestamp = timestamp
	@nonce = nonce
	@signature = signature
	@echostr = echostr
end

Instance Method Details

#check_validObject



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