Class: WeChat::Messaging::MessageValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/we_chat/messaging/message_validator.rb

Class Method Summary collapse

Class Method Details

.is_valid?(signature, timestamp, nonce, token) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
# File 'lib/we_chat/messaging/message_validator.rb', line 6

def self.is_valid?(signature, timestamp, nonce, token)
  tmpArray = [token, timestamp, nonce].sort
  tmpString = tmpArray.join
  new_signature = Digest::SHA1.hexdigest tmpString
  return false if signature.nil?
  new_signature == signature
end