1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| function p(e) { var t = new Array , n = 0; for (var i in e) t[n] = i, n++; var r = [].concat(t).sort() , o = {}; for (var a in r) o[r[a]] = e[r[a]]; return o }
function m(e) { var t = {} , n = ["signData", "encData", "extra"]; for (var i in e) e.hasOwnProperty(i) && !n.includes(i) && null != e[i] && (t[i] = e[i]); return t }
function v(e) { var t = []; for (var n in e) if (e.hasOwnProperty(n) && (e[n] || "".concat(e[n]))) if ("data" === n) { var i = Object.assign({}, e[n]); for (var r in i) { if ("number" != typeof i[r] && "boolean" != typeof i[r] || (i[r] = "" + i[r]), Array.isArray(i[r]) && !i[r].length && delete i[r], Array.isArray(i[r]) && i[r].length > 0) for (var o = 0; o < i[r].length; o++) i[r][o] = p(i[r][o]); null != i[r] && i[r] || delete i[r] } var a = p(i); t.push("".concat(n, "=").concat(JSON.stringify(a))) } else t.push("".concat(n, "=").concat(e[n])); return t.push("key=".concat('NMVFVILMKT13GEMD3BKPKCTBOQBPZR2P')), t.join("&") }
sm4 = require('sm-crypto').sm4; r = xxx("68b2") o = r.sm2 a = r.sm3 s = r.sm4 l = (xxx("94f8"), { appCode: "T98HPCGN5ZVVQBS8LZQNOAEXVI9GYHKQ", version: "1.0.0", appSecret: "NMVFVILMKT13GEMD3BKPKCTBOQBPZR2P", publicKey: "BEKaw3Qtc31LG/hTPHFPlriKuAn/nzTWl8LiRxLw4iQiSUIyuglptFxNkdCiNXcXvkqTH79Rh/A2sEFU6hjeK3k=", privateKey: "AJxKNdmspMaPGj+onJNoQ0cgWk2E3CYFWKBJhpcJrAtC", publicKeyType: "base64", privateKeyType: "base64" }) signData = function (t) { e = xxx("b639").Buffer var n = m(t) , i = p(n);
i.data = p(i.data); var r = v(i)
, a = o.doSignature(r, e.from(l.privateKey, "base64").toString("hex"), { hash: !0 }); return e.from(a, "hex").toString("base64")
}
function A(e) { var t, n, i = new Array; t = e.length; for (var r = 0; r < t; r++) (n = e.charCodeAt(r)) >= 65536 && n <= 1114111 ? (i.push(n >> 18 & 7 | 240), i.push(n >> 12 & 63 | 128), i.push(n >> 6 & 63 | 128), i.push(63 & n | 128)) : n >= 2048 && n <= 65535 ? (i.push(n >> 12 & 15 | 224), i.push(n >> 6 & 63 | 128), i.push(63 & n | 128)) : n >= 128 && n <= 2047 ? (i.push(n >> 6 & 31 | 192), i.push(63 & n | 128)) : i.push(255 & n); return i } function b(t, n) { var i = 16 - parseInt(n.length % 16); n = n.concat(new Array(i).fill(i)); var r = s.encrypt(n, t); return e.from(r).toString("hex") } function y(e, t) { return A(b(A(e.substr(0, 16)), A(t)).toUpperCase().substr(0, 16)) } function encdata(e) {
var t = e.data && JSON.stringify(e.data) , n = A(t); u = e.appCode; c = l.appSecret; var i = y(u, c) , r = b(i, n); return r.toUpperCase()
}
function get_data(dd) { sign_data = signData(dd) encData = encdata(dd) return { "sign_data": sign_data, 'encData': encData } } ccc = { "data": { "addr": "", "regnCode": "430100", "medinsName": "", "medinsLvCode": "", "medinsTypeCode": "", "openElec": "", "pageNum": 7, "pageSize": 10, "queryDataSource": "es" }, "appCode": "T98HPCGN5ZVVQBS8LZQNOAEXVI9GYHKQ", "version": "1.0.0", "encType": "SM4", "signType": "SM2", "timestamp": 1697963445 } console.log(get_data(ccc))
|