# 单双引号引起的数字签名拼接错误

需求,数字证书生成

 const inputFocus = (event) => {
    console.log("inputFocus");
    console.log("6666", TimeStamp, Random, AccountCode, SignToken);
    let signature = getSingature(TimeStamp, Random, AccountCode, SignToken, "");    //单引号会生成错误的签名

    console.log(signature, "signature");

    let headers = {
      accountcode: AccountCode,
      timestamp: TimeStamp,
      nonce: Random,
      signature,
    };
    const res = http.get("/api/project/GetProjectInfoByAccount", null, headers);
    res.then((res) => {});
  };
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//获取signature
export function getSingature(timestamp, nonce, accountId, token, data) {
  console.log(accountId, token, data, "(编号,signtoken,传参值)");
  var signStr = "" + timestamp + nonce + accountId + token + data;
  var sortStr = signStr.split("");
  sortStr.sort(); //////升序
  signStr = sortStr.join("");
  var md5val = md5.array(encodeUtf8(signStr));
  var result = "";
  result = Bytes2Str(md5val);
  result = result.toUpperCase();
  return result;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
上次更新: 8/9/2022, 19:37:12