鍍金池/ 問(wèn)答/網(wǎng)絡(luò)營(yíng)銷(xiāo)  HTML/ 求 nodejs 微信加解密代碼

求 nodejs 微信加解密代碼

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

回答
編輯回答
來(lái)守候
      // 1.獲取微信服務(wù)器Get請(qǐng)求的參數(shù) signature、timestamp、nonce、echostr
      // 2.將token、timestamp、nonce三個(gè)參數(shù)進(jìn)行字典序排序
      let array = [config.wechat.token, ctx.query.timestamp, ctx.query.nonce]
      array.sort()
      // 3.將三個(gè)參數(shù)字符串拼接成一個(gè)字符串進(jìn)行sha1加密
      let resultCode = _util.hashCry(array.join(''))
exports.hashCry = str => {
  const hashCode = crypto.createHash('sha1') // 創(chuàng)建加密類(lèi)型
  return hashCode.update(str, 'utf8').digest('hex')
}
2017年4月13日 20:51