Showing
1 changed file
with
8 additions
and
3 deletions
@@ -5,8 +5,7 @@ | @@ -5,8 +5,7 @@ | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | - | ||
9 | -const qs = require('querystring'); | 8 | +const _ = require('lodash'); |
10 | const md5 = require('md5'); | 9 | const md5 = require('md5'); |
11 | 10 | ||
12 | const privateKey = { | 11 | const privateKey = { |
@@ -39,7 +38,13 @@ const packageSort = argument => { | @@ -39,7 +38,13 @@ const packageSort = argument => { | ||
39 | * @return {string} 生成的签名字符串 | 38 | * @return {string} 生成的签名字符串 |
40 | */ | 39 | */ |
41 | const makeSign = argument => { | 40 | const makeSign = argument => { |
42 | - return md5(qs.stringify(argument)).toLowerCase(); | 41 | + var qs = []; |
42 | + | ||
43 | + _.forEach(argument, function(value, key) { | ||
44 | + qs.push(key + '=' + _.trim(value)); | ||
45 | + }); | ||
46 | + | ||
47 | + return md5(qs.join('&')).toLowerCase(); | ||
43 | }; | 48 | }; |
44 | 49 | ||
45 | // 生成API签名,调用后端接口的时候有私钥校验 | 50 | // 生成API签名,调用后端接口的时候有私钥校验 |
-
Please register or login to post a comment