crypto-js 计算 checksumhash


crypto-js 计算 checksumhash

https://github.com/brix/crypto-js/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
      let CryptoJS = require('crypto-js')

let pp = [];
for(let key in params){
pp.push(key+'='+params[key]);
}
// 排序
pp = pp.sort();
let check = '';
for (let i=0;i<pp.length ;i++ )
{
check += pp[i].replace('=','');
}
check += checksumhashkey;
// 计算 checksumhash
let checksumhash = CryptoJS.MD5(check).toString();
checksumhash = CryptoJS.enc.Hex.parse(checksumhash).toString();
params.checksumhash = checksumhash;