Class: Wechat::Callback::Signature
- Inherits:
-
Object
- Object
- Wechat::Callback::Signature
- Defined in:
- lib/wechat/callback/signature.rb
Class Method Summary collapse
Class Method Details
.create(token, timestamp, nonce, *args) ⇒ Object
token 可由开发者在开发者中心配置项任意填写timestamp 时间戳nonce 随机数
加密/校验流程如下:
-
将token、timestamp、nonce三个参数进行字典序排序
-
将三个参数字符串拼接成一个字符串进行sha1加密
-
开发者获得加密后的字符串可与signature对比,标识该请求来源于微信
15 16 17 |
# File 'lib/wechat/callback/signature.rb', line 15 def self.create(token, , nonce, *args) Digest::SHA1.hexdigest [ token, nonce, , *args ].sort.join('') end |