求 nodejs 微信加解密代码

求 nodejs 微信加解密代码,微信只提供了 C++、php、Java、Python 和 C# 版。

阅读 4.2k
1 个回答
      // 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')
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题