class Wechat::Callback::Signature
Singature 用于生成参数签名。
Public Class Methods
create(token, timestamp, nonce, *args)
click to toggle source
token 可由开发者在开发者中心配置项任意填写 timestamp 时间戳 nonce 随机数
加密/校验流程如下:
-
将token、timestamp、nonce三个参数进行字典序排序
-
将三个参数字符串拼接成一个字符串进行sha1加密
-
开发者获得加密后的字符串可与signature对比,标识该请求来源于微信
# File lib/wechat/callback/signature.rb, line 21 def self.create(token, timestamp, nonce, *args) assert_present! :token, token assert_present! :timestamp, timestamp assert_present! :nonce, nonce Digest::SHA1.hexdigest [ token, nonce, timestamp, *args ].sort.join end