var genSignData = function(e) { var t = "" , n = []; for (var r in e) n.push(r); n = n.sort(); for (var i = 0; i < n.length; i++) { var o = n[i] , s = e[o] , l = !1; if ("object" == ("undefined" == typeof s ? "undefined" : (0, a.default)(s))) { var c = "{"; for (var u in s) c += u + "=" + s[u] + ", ", l = !0; l && (s = c.substring(0, c.length - 2) + "}") } "sign" != o && null !== s && void 0 !== s && "" !== s && ("object" != ("undefined" == typeof s ? "undefined" : (0, a.default)(s)) || l) && (t += (0 == i ? "" : "&") + o + "=" + s) } return null != t && "" != t && "&" == t.substr(0, 1) && (t = t.substr(1, t.length)), t }
单独运行时报错Uncaught ReferenceError: a is not defined,打印a.default
var liu94 = function (e, t) { var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" , n = { rotl: function (e, t) { return e << t | e >>> 32 - t }, rotr: function (e, t) { return e << 32 - t | e >>> t }, endian: function (e) { if (e.constructor == Number) return 16711935 & n.rotl(e, 8) | 4278255360 & n.rotl(e, 24); for (var t = 0; t < e.length; t++) e[t] = n.endian(e[t]); return e }, randomBytes: function (e) { for (var t = []; e > 0; e--) t.push(Math.floor(256 * Math.random())); return t }, bytesToWords: function (e) { for (var t = [], n = 0, r = 0; n < e.length; n++, r += 8) t[r >>> 5] |= e[n] << 24 - r % 32; return t }, wordsToBytes: function (e) { for (var t = [], n = 0; n < 32 * e.length; n += 8) t.push(e[n >>> 5] >>> 24 - n % 32 & 255); return t }, bytesToHex: function (e) { for (var t = [], n = 0; n < e.length; n++) t.push((e[n] >>> 4).toString(16)), t.push((15 & e[n]).toString(16)); return t.join("") }, hexToBytes: function (e) { for (var t = [], n = 0; n < e.length; n += 2) t.push(parseInt(e.substr(n, 2), 16)); return t }, bytesToBase64: function (e) { for (var n = [], r = 0; r < e.length; r += 3) for (var i = e[r] << 16 | e[r + 1] << 8 | e[r + 2], a = 0; a < 4; a++) 8 * r + 6 * a <= 8 * e.length ? n.push(t.charAt(i >>> 6 * (3 - a) & 63)) : n.push("="); return n.join("") }, base64ToBytes: function (e) { e = e.replace(/[^A-Z0-9+\/]/gi, ""); for (var n = [], r = 0, i = 0; r < e.length; i = ++r % 4) 0 != i && n.push((t.indexOf(e.charAt(r - 1)) & Math.pow(2, -2 * i + 8) - 1) << 2 * i | t.indexOf(e.charAt(r)) >>> 6 - 2 * i); return n } }; return n; }
var er47 = { utf8: { stringToBytes: function (e) { return er47.bin.stringToBytes(unescape(encodeURIComponent(e))) }, bytesToString: function (e) { return decodeURIComponent(escape(er47.bin.bytesToString(e))) } }, bin: { stringToBytes: function (e) { for (var t = [], n = 0; n < e.length; n++) t.push(255 & e.charCodeAt(n)); return t }, bytesToString: function (e) { for (var t = [], n = 0; n < e.length; n++) t.push(String.fromCharCode(e[n])); return t.join("") } } };
var jiu74 = function (e, t) { function n(e) { return !!e.constructor && "function" == typeof e.constructor.isBuffer && e.constructor.isBuffer(e) } function r(e) { return "function" == typeof e.readFloatLE && "function" == typeof e.slice && n(e.slice(0, 0)) } return function (e) { return null != e && (n(e) || r(e) || !!e._isBuffer) } }
在o函数中改写t,r,i,a
1 2 3 4
var t = liu94() , r = er47.utf8 , i = jiu74() , a = er47.bin
最终只要将o函数中exports的函数return出来即可
1 2 3 4 5 6 7 8 9 10 11
res = function (e, n) { console.log(e) if (void 0 === e || null === e) throw new Error("Illegal argument " + e); var r = t.wordsToBytes(o(e, n)); console.log(r) return n && n.asBytes ? r : n && n.asString ? a.bytesToString(r) : t.bytesToHex(r) } //res("password=123&userName=158062204095", undefined); //console.log('-------->',res(origin, undefined)) return res;