yoho.js
542 Bytes
const _ = require('lodash');
const md5 = require('yoho-md5');
const yoho = {
getSign(params, clientSecret) {
let secretParams = {},
secretStr = '';
for (const k of Object.keys(params).sort()) {
if (k === 'yh_sign') {
continue;
}
secretParams[k] = params[k];
}
secretStr = _.join(_.map(secretParams, (v, k) => {
return `${k}=${v}`;
}), '&');
return md5(secretStr + clientSecret);
}
};
module.exports = yoho;