// 1.获取微信服务器Get请求的参数 signature、timestamp、nonce、echostr // 2.将token、timestamp、nonce三个参数进行字典序排序 let array = [config.wechat.token, ctx.query.timestamp, ctx.query.nonce] array.sort() // 3.将三个参数字符串拼接成一个字符串进行sha1加密 let resultCode = _util.hashCry(array.join('')) exports.hashCry = str => { const hashCode = crypto.createHash('sha1') // 创建加密类型 return hashCode.update(str, 'utf8').digest('hex') }