网址:aHR0cHM6Ly9wYXNzcG9ydC53YW5tZWkuY29tL2xvZ2lu
点击登录,抓包分析,不出意外password进行了加密
直接搜索关键词password,找到加密js文件 ,看见setPublicKey,似乎是RSA的加密算法
分析到这里不用分析了,我直接搜索出了加密的整个文件。
倒数第二个文件,复制整个文件内容,发现是老朋友,自运行函数,打开新的页面,在浏览器运行,直接出现了结果。
在pycharm中运行,经过补环境后完整代码
const{JSDOM} = require('jsdom');
const dom = new JSDOM('<!DOCTYPE html><p> Hello world</p>');
window = dom.window;
navigator = window.navigator;
(function(av) {
function l() {
this.i = 0;
this.j = 0;
this.S = new Array()
}
function f(aI) {
var aH, z, aG;
for (aH = 0; aH < 256; ++aH) {
this.S[aH] = aH
}
z = 0;
for (aH = 0; aH < 256; ++aH) {
z = (z + this.S[aH] + aI[aH % aI.length]) & 255;
aG = this.S[aH];
this.S[aH] = this.S[z];
this.S[z] = aG
}
this.i = 0;
this.j = 0
}
function b() {
var z;
this.i = (this.i + 1) & 255;
this.j = (this.j + this.S[this.i]) & 255;
z = this.S[this.i];
this.S[this.i] = this.S[this.j];
this.S[this.j] = z;
return this.S[(z + this.S[this.i]) & 255]
}
l.prototype.init = f;
l.prototype.next = b;
function au() {
return new l()
}
var O = 256;
var n;
var V;
var ag;
function d(t) {
V[ag++] ^= t & 255;
V[ag++] ^= (t >> 8) & 255;
V[ag++] ^= (t >> 16) & 255;
V[ag++] ^= (t >> 24) & 255;
if (ag >= O) {
ag -= O
}
}
function U() {
d(new Date().getTime())
}
if (V == null) {
V = new Array();
ag = 0;
var K;
// if (navigator.appName == "Netscape" && navigator.appVersion < "5" && av.crypto) {
// var H = av.crypto.random(32);
// for (K = 0; K < H.length; ++K) {
// V[ag++] = H.charCodeAt(K) & 255
// }
// }
while (ag < O) {
K = Math.floor(65536 * Math.random());
V[ag++] = K >>> 8;
V[ag++] = K & 255
}
ag = 0;
U()
}
function E() {
if (n == null) {
U();
n = au();
n.init(V);
for (ag = 0; ag < V.length; ++ag) {
V[ag] = 0
}
ag = 0
}
return n.next()
}
function aB(z) {
var t;
for (t = 0; t < z.length; ++t) {
z[t] = E()
}
}
function ah() {}
ah.prototype.nextBytes = aB;
var aC;
var an = 244837814094590;
var ac = ((an & 16777215) == 15715070);
function ay(z, t, aG) {
if (z != null) {
if ("number" == typeof z) {
this.fromNumber(z, t, aG)
} else {
if (t == null && "string" != typeof z) {
this.fromString(z, 256)
} else {
this.fromString(z, t)
}
}
}
}
function i() {
return new ay(null)
}
function c(aI, t, z, aH, aK, aJ) {
while (--aJ >= 0) {
var aG = t * this[aI++] + z[aH] + aK;
aK = Math.floor(aG / 67108864);
z[aH++] = aG & 67108863
}
return aK
}
function aE(aI, aN, aO, aH, aL, t) {
var aK = aN & 32767
, aM = aN >> 15;
while (--t >= 0) {
var aG = this[aI] & 32767;
var aJ = this[aI++] >> 15;
var z = aM * aG + aJ * aK;
aG = aK * aG + ((z & 32767) << 15) + aO[aH] + (aL & 1073741823);
aL = (aG >>> 30) + (z >>> 15) + aM * aJ + (aL >>> 30);
aO[aH++] = aG & 1073741823
}
return aL
}
function aD(aI, aN, aO, aH, aL, t) {
var aK = aN & 16383
, aM = aN >> 14;
while (--t >= 0) {
var aG = this[aI] & 16383;
var aJ = this[aI++] >> 14;
var z = aM * aG + aJ * aK;
aG = aK * aG + ((z & 16383) << 14) + aO[aH] + aL;
aL = (aG >> 28) + (z >> 14) + aM * aJ;
aO[aH++] = aG & 268435455
}
return aL
}
if (ac && (navigator.appName == "Microsoft Internet Explorer")) {
ay.prototype.am = aE;
aC = 30
} else {
if (ac && (navigator.appName != "Netscape")) {
ay.prototype.am = c;
aC = 26
} else {
ay.prototype.am = aD;
aC = 28
}
}
ay.prototype.DB = aC;
ay.prototype.DM = ((1 << aC) - 1);
ay.prototype.DV = (1 << aC);
var ae = 52;
ay.prototype.FV = Math.pow(2, ae);
ay.prototype.F1 = ae - aC;
ay.prototype.F2 = 2 * aC - ae;
var aj = "0123456789abcdefghijklmnopqrstuvwxyz";
var al = new Array();
var aw, x;
aw = "0".charCodeAt(0);
for (x = 0; x <= 9; ++x) {
al[aw++] = x
}
aw = "a".charCodeAt(0);
for (x = 10; x < 36; ++x) {
al[aw++] = x
}
aw = "A".charCodeAt(0);
for (x = 10; x < 36; ++x) {
al[aw++] = x
}
function aF(t) {
return aj.charAt(t)
}
function C(z, t) {
var aG = al[z.charCodeAt(t)];
return (aG == null) ? -1 : aG
}
function ab(z) {
for (var t = this.t - 1; t >= 0; --t) {
z[t] = this[t]
}
z.t = this.t;
z.s = this.s
}
function o(t) {
this.t = 1;
this.s = (t < 0) ? -1 : 0;
if (t > 0) {
this[0] = t
} else {
if (t < -1) {
this[0] = t + DV
} else {
this.t = 0
}
}
}
function e(t) {
var z = i();
z.fromInt(t);
return z
}
function y(aK, z) {
var aH;
if (z == 16) {
aH = 4
} else {
if (z == 8) {
aH = 3
} else {
if (z == 256) {
aH = 8
} else {
if (z == 2) {
aH = 1
} else {
if (z == 32) {
aH = 5
} else {
if (z == 4) {
aH = 2
} else {
this.fromRadix(aK, z);
return
}
}
}
}
}
}
this.t = 0;
this.s = 0;
var aJ = aK.length
, aG = false
, aI = 0;
while (--aJ >= 0) {
var t = (aH == 8) ? aK[aJ] & 255 : C(aK, aJ);
if (t < 0) {
if (aK.charAt(aJ) == "-") {
aG = true
}
continue
}
aG = false;
if (aI == 0) {
this[this.t++] = t
} else {
if (aI + aH > this.DB) {
this[this.t - 1] |= (t & ((1 << (this.DB - aI)) - 1)) << aI;
this[this.t++] = (t >> (this.DB - aI))
} else {
this[this.t - 1] |= t << aI
}
}
aI += aH;
if (aI >= this.DB) {
aI -= this.DB
}
}
if (aH == 8 && (aK[0] & 128) != 0) {
this.s = -1;
if (aI > 0) {
this[this.t - 1] |= ((1 << (this.DB - aI)) - 1) << aI
}
}
this.clamp();
if (aG) {
ay.ZERO.subTo(this, this)
}
}
function Q() {
var t = this.s & this.DM;
while (this.t > 0 && this[this.t - 1] == t) {
--this.t
}
}
function r(z) {
if (this.s < 0) {
return "-" + this.negate().toString(z)
}
var aG;
if (z == 16) {
aG = 4
} else {
if (z == 8) {
aG = 3
} else {
if (z == 2) {
aG = 1
} else {
if (z == 32) {
aG = 5
} else {
if (z == 4) {
aG = 2
} else {
return this.toRadix(z)
}
}
}
}
}
var aI = (1 << aG) - 1, aL, t = false, aJ = "", aH = this.t;
var aK = this.DB - (aH * this.DB) % aG;
if (aH-- > 0) {
if (aK < this.DB && (aL = this[aH] >> aK) > 0) {
t = true;
aJ = aF(aL)
}
while (aH >= 0) {
if (aK < aG) {
aL = (this[aH] & ((1 << aK) - 1)) << (aG - aK);
aL |= this[--aH] >> (aK += this.DB - aG)
} else {
aL = (this[aH] >> (aK -= aG)) & aI;
if (aK <= 0) {
aK += this.DB;
--aH
}
}
if (aL > 0) {
t = true
}
if (t) {
aJ += aF(aL)
}
}
}
return t ? aJ : "0"
}
function T() {
var t = i();
ay.ZERO.subTo(this, t);
return t
}
function aq() {
return (this.s < 0) ? this.negate() : this
}
function I(t) {
var aG = this.s - t.s;
if (aG != 0) {
return aG
}
var z = this.t;
aG = z - t.t;
if (aG != 0) {
return aG
}
while (--z >= 0) {
if ((aG = this[z] - t[z]) != 0) {
return aG
}
}
return 0
}
function k(z) {
var aH = 1, aG;
if ((aG = z >>> 16) != 0) {
z = aG;
aH += 16
}
if ((aG = z >> 8) != 0) {
z = aG;
aH += 8
}
if ((aG = z >> 4) != 0) {
z = aG;
aH += 4
}
if ((aG = z >> 2) != 0) {
z = aG;
aH += 2
}
if ((aG = z >> 1) != 0) {
z = aG;
aH += 1
}
return aH
}
function w() {
if (this.t <= 0) {
return 0
}
return this.DB * (this.t - 1) + k(this[this.t - 1] ^ (this.s & this.DM))
}
function ax(aG, z) {
var t;
for (t = this.t - 1; t >= 0; --t) {
z[t + aG] = this[t]
}
for (t = aG - 1; t >= 0; --t) {
z[t] = 0
}
z.t = this.t + aG;
z.s = this.s
}
function aa(aG, z) {
for (var t = aG; t < this.t; ++t) {
z[t - aG] = this[t]
}
z.t = Math.max(this.t - aG, 0);
z.s = this.s
}
function u(aL, aH) {
var z = aL % this.DB;
var t = this.DB - z;
var aJ = (1 << t) - 1;
var aI = Math.floor(aL / this.DB), aK = (this.s << z) & this.DM, aG;
for (aG = this.t - 1; aG >= 0; --aG) {
aH[aG + aI + 1] = (this[aG] >> t) | aK;
aK = (this[aG] & aJ) << z
}
for (aG = aI - 1; aG >= 0; --aG) {
aH[aG] = 0
}
aH[aI] = aK;
aH.t = this.t + aI + 1;
aH.s = this.s;
aH.clamp()
}
function m(aK, aH) {
aH.s = this.s;
var aI = Math.floor(aK / this.DB);
if (aI >= this.t) {
aH.t = 0;
return
}
var z = aK % this.DB;
var t = this.DB - z;
var aJ = (1 << z) - 1;
aH[0] = this[aI] >> z;
for (var aG = aI + 1; aG < this.t; ++aG) {
aH[aG - aI - 1] |= (this[aG] & aJ) << t;
aH[aG - aI] = this[aG] >> z
}
if (z > 0) {
aH[this.t - aI - 1] |= (this.s & aJ) << t
}
aH.t = this.t - aI;
aH.clamp()
}
function af(z, aH) {
var aG = 0
, aI = 0
, t = Math.min(z.t, this.t);
while (aG < t) {
aI += this[aG] - z[aG];
aH[aG++] = aI & this.DM;
aI >>= this.DB
}
if (z.t < this.t) {
aI -= z.s;
while (aG < this.t) {
aI += this[aG];
aH[aG++] = aI & this.DM;
aI >>= this.DB
}
aI += this.s
} else {
aI += this.s;
while (aG < z.t) {
aI -= z[aG];
aH[aG++] = aI & this.DM;
aI >>= this.DB
}
aI -= z.s
}
aH.s = (aI < 0) ? -1 : 0;
if (aI < -1) {
aH[aG++] = this.DV + aI
} else {
if (aI > 0) {
aH[aG++] = aI
}
}
aH.t = aG;
aH.clamp()
}
function F(z, aH) {
var t = this.abs()
, aI = z.abs();
var aG = t.t;
aH.t = aG + aI.t;
while (--aG >= 0) {
aH[aG] = 0
}
for (aG = 0; aG < aI.t; ++aG) {
aH[aG + t.t] = t.am(0, aI[aG], aH, aG, 0, t.t)
}
aH.s = 0;
aH.clamp();
if (this.s != z.s) {
ay.ZERO.subTo(aH, aH)
}
}
function S(aG) {
var t = this.abs();
var z = aG.t = 2 * t.t;
while (--z >= 0) {
aG[z] = 0
}
for (z = 0; z < t.t - 1; ++z) {
var aH = t.am(z, t[z], aG, 2 * z, 0, 1);
if ((aG[z + t.t] += t.am(z + 1, 2 * t[z], aG, 2 * z + 1, aH, t.t - z - 1)) >= t.DV) {
aG[z + t.t] -= t.DV;
aG[z + t.t + 1] = 1
}
}
if (aG.t > 0) {
aG[aG.t - 1] += t.am(z, t[z], aG, 2 * z, 0, 1)
}
aG.s = 0;
aG.clamp()
}
function G(aO, aL, aK) {
var aU = aO.abs();
if (aU.t <= 0) {
return
}
var aM = this.abs();
if (aM.t < aU.t) {
if (aL != null) {
aL.fromInt(0)
}
if (aK != null) {
this.copyTo(aK)
}
return
}
if (aK == null) {
aK = i()
}
var aI = i()
, z = this.s
, aN = aO.s;
var aT = this.DB - k(aU[aU.t - 1]);
if (aT > 0) {
aU.lShiftTo(aT, aI);
aM.lShiftTo(aT, aK)
} else {
aU.copyTo(aI);
aM.copyTo(aK)
}
var aQ = aI.t;
var aG = aI[aQ - 1];
if (aG == 0) {
return
}
var aP = aG * (1 << this.F1) + ((aQ > 1) ? aI[aQ - 2] >> this.F2 : 0);
var aX = this.FV / aP
, aW = (1 << this.F1) / aP
, aV = 1 << this.F2;
var aS = aK.t
, aR = aS - aQ
, aJ = (aL == null) ? i() : aL;
aI.dlShiftTo(aR, aJ);
if (aK.compareTo(aJ) >= 0) {
aK[aK.t++] = 1;
aK.subTo(aJ, aK)
}
ay.ONE.dlShiftTo(aQ, aJ);
aJ.subTo(aI, aI);
while (aI.t < aQ) {
aI[aI.t++] = 0
}
while (--aR >= 0) {
var aH = (aK[--aS] == aG) ? this.DM : Math.floor(aK[aS] * aX + (aK[aS - 1] + aV) * aW);
if ((aK[aS] += aI.am(0, aH, aK, aR, 0, aQ)) < aH) {
aI.dlShiftTo(aR, aJ);
aK.subTo(aJ, aK);
while (aK[aS] < --aH) {
aK.subTo(aJ, aK)
}
}
}
if (aL != null) {
aK.drShiftTo(aQ, aL);
if (z != aN) {
ay.ZERO.subTo(aL, aL)
}
}
aK.t = aQ;
aK.clamp();
if (aT > 0) {
aK.rShiftTo(aT, aK)
}
if (z < 0) {
ay.ZERO.subTo(aK, aK)
}
}
function P(t) {
var z = i();
this.abs().divRemTo(t, null, z);
if (this.s < 0 && z.compareTo(ay.ZERO) > 0) {
t.subTo(z, z)
}
return z
}
function M(t) {
this.m = t
}
function X(t) {
if (t.s < 0 || t.compareTo(this.m) >= 0) {
return t.mod(this.m)
} else {
return t
}
}
function ap(t) {
return t
}
function L(t) {
t.divRemTo(this.m, null, t)
}
function J(t, aG, z) {
t.multiplyTo(aG, z);
this.reduce(z)
}
function aA(t, z) {
t.squareTo(z);
this.reduce(z)
}
M.prototype.convert = X;
M.prototype.revert = ap;
M.prototype.reduce = L;
M.prototype.mulTo = J;
M.prototype.sqrTo = aA;
function D() {
if (this.t < 1) {
return 0
}
var t = this[0];
if ((t & 1) == 0) {
return 0
}
var z = t & 3;
z = (z * (2 - (t & 15) * z)) & 15;
z = (z * (2 - (t & 255) * z)) & 255;
z = (z * (2 - (((t & 65535) * z) & 65535))) & 65535;
z = (z * (2 - t * z % this.DV)) % this.DV;
return (z > 0) ? this.DV - z : -z
}
function g(t) {
this.m = t;
this.mp = t.invDigit();
this.mpl = this.mp & 32767;
this.mph = this.mp >> 15;
this.um = (1 << (t.DB - 15)) - 1;
this.mt2 = 2 * t.t
}
function ao(t) {
var z = i();
t.abs().dlShiftTo(this.m.t, z);
z.divRemTo(this.m, null, z);
if (t.s < 0 && z.compareTo(ay.ZERO) > 0) {
this.m.subTo(z, z)
}
return z
}
function az(t) {
var z = i();
t.copyTo(z);
this.reduce(z);
return z
}
function R(t) {
while (t.t <= this.mt2) {
t[t.t++] = 0
}
for (var aG = 0; aG < this.m.t; ++aG) {
var z = t[aG] & 32767;
var aH = (z * this.mpl + (((z * this.mph + (t[aG] >> 15) * this.mpl) & this.um) << 15)) & t.DM;
z = aG + this.m.t;
t[z] += this.m.am(0, aH, t, aG, 0, this.m.t);
while (t[z] >= t.DV) {
t[z] -= t.DV;
t[++z]++
}
}
t.clamp();
t.drShiftTo(this.m.t, t);
if (t.compareTo(this.m) >= 0) {
t.subTo(this.m, t)
}
}
function ar(t, z) {
t.squareTo(z);
this.reduce(z)
}
function B(t, aG, z) {
t.multiplyTo(aG, z);
this.reduce(z)
}
g.prototype.convert = ao;
g.prototype.revert = az;
g.prototype.reduce = R;
g.prototype.mulTo = B;
g.prototype.sqrTo = ar;
function j() {
return ((this.t > 0) ? (this[0] & 1) : this.s) == 0
}
function A(aL, aM) {
if (aL > 4294967295 || aL < 1) {
return ay.ONE
}
var aK = i()
, aG = i()
, aJ = aM.convert(this)
, aI = k(aL) - 1;
aJ.copyTo(aK);
while (--aI >= 0) {
aM.sqrTo(aK, aG);
if ((aL & (1 << aI)) > 0) {
aM.mulTo(aG, aJ, aK)
} else {
var aH = aK;
aK = aG;
aG = aH
}
}
return aM.revert(aK)
}
function at(aG, t) {
var aH;
if (aG < 256 || t.isEven()) {
aH = new M(t)
} else {
aH = new g(t)
}
return this.exp(aG, aH)
}
ay.prototype.copyTo = ab;
ay.prototype.fromInt = o;
ay.prototype.fromString = y;
ay.prototype.clamp = Q;
ay.prototype.dlShiftTo = ax;
ay.prototype.drShiftTo = aa;
ay.prototype.lShiftTo = u;
ay.prototype.rShiftTo = m;
ay.prototype.subTo = af;
ay.prototype.multiplyTo = F;
ay.prototype.squareTo = S;
ay.prototype.divRemTo = G;
ay.prototype.invDigit = D;
ay.prototype.isEven = j;
ay.prototype.exp = A;
ay.prototype.toString = r;
ay.prototype.negate = T;
ay.prototype.abs = aq;
ay.prototype.compareTo = I;
ay.prototype.bitLength = w;
ay.prototype.mod = P;
ay.prototype.modPowInt = at;
ay.ZERO = e(0);
ay.ONE = e(1);
function h(z, t) {
return new ay(z,t)
}
function am(aG, aH) {
var t = "";
var z = 0;
while (z + aH < aG.length) {
t += aG.substring(z, z + aH) + "\n";
z += aH
}
return t + aG.substring(z, aG.length)
}
function s(t) {
if (t < 16) {
return "0" + t.toString(16)
} else {
return t.toString(16)
}
}
function ak(aH, aK) {
if (aK < aH.length + 11) {
alert("Message too long for RSA");
return null
}
var aJ = new Array();
var aG = aH.length - 1;
while (aG >= 0 && aK > 0) {
var aI = aH.charCodeAt(aG--);
if (aI < 128) {
aJ[--aK] = aI
} else {
if ((aI > 127) && (aI < 2048)) {
aJ[--aK] = (aI & 63) | 128;
aJ[--aK] = (aI >> 6) | 192
} else {
aJ[--aK] = (aI & 63) | 128;
aJ[--aK] = ((aI >> 6) & 63) | 128;
aJ[--aK] = (aI >> 12) | 224
}
}
}
aJ[--aK] = 0;
var z = new ah();
var t = new Array();
while (aK > 2) {
t[0] = 0;
while (t[0] == 0) {
z.nextBytes(t)
}
aJ[--aK] = t[0]
}
aJ[--aK] = 2;
aJ[--aK] = 0;
return new ay(aJ)
}
function N() {
this.n = null;
this.e = 0;
this.d = null;
this.p = null;
this.q = null;
this.dmp1 = null;
this.dmq1 = null;
this.coeff = null
}
function p(z, t) {
if (z != null && t != null && z.length > 0 && t.length > 0) {
this.n = h(z, 16);
this.e = parseInt(t, 16)
} else {
alert("Invalid RSA public key")
}
}
function Z(t) {
return t.modPowInt(this.e, this.n)
}
function q(aG) {
var t = ak(aG, (this.n.bitLength() + 7) >> 3);
if (t == null) {
return null
}
var aH = this.doPublic(t);
if (aH == null) {
return null
}
var z = aH.toString(16);
if ((z.length & 1) == 0) {
return z
} else {
return "0" + z
}
}
N.prototype.doPublic = Z;
N.prototype.setPublic = p;
N.prototype.encrypt = q;
var ad = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var Y = "=";
function ai(aG) {
var z;
var aH;
var t = "";
for (z = 0; z + 3 <= aG.length; z += 3) {
aH = parseInt(aG.substring(z, z + 3), 16);
t += ad.charAt(aH >> 6) + ad.charAt(aH & 63)
}
if (z + 1 == aG.length) {
aH = parseInt(aG.substring(z, z + 1), 16);
t += ad.charAt(aH << 2)
} else {
if (z + 2 == aG.length) {
aH = parseInt(aG.substring(z, z + 2), 16);
t += ad.charAt(aH >> 2) + ad.charAt((aH & 3) << 4)
}
}
while ((t.length & 3) > 0) {
t += Y
}
return t
}
function a(aI) {
var aG = "";
var aH;
var t = 0;
var z;
for (aH = 0; aH < aI.length; ++aH) {
if (aI.charAt(aH) == Y) {
break
}
v = ad.indexOf(aI.charAt(aH));
if (v < 0) {
continue
}
if (t == 0) {
aG += aF(v >> 2);
z = v & 3;
t = 1
} else {
if (t == 1) {
aG += aF((z << 2) | (v >> 4));
z = v & 15;
t = 2
} else {
if (t == 2) {
aG += aF(z);
aG += aF(v >> 2);
z = v & 3;
t = 3
} else {
aG += aF((z << 2) | (v >> 4));
aG += aF(v & 15);
t = 0
}
}
}
}
if (t == 1) {
aG += aF(z << 2)
}
return aG
}
function W(aH) {
var aG = a(aH);
var z;
var t = new Array();
for (z = 0; 2 * z < aG.length; ++z) {
t[z] = parseInt(aG.substring(2 * z, 2 * z + 2), 16)
}
return t
}
av.encrypt = function(aG, z) {
var t = new N();
t.setPublic(a(aG), "10001");
return ai(t.encrypt(z))
}
}
)(window);
password = '123456'
public_key = 'ANKi9PWuvDOsagwIVvrPx77mXNV0APmjySsYjB1/GtUTY6cyKNRl2RCTt608m9nYk5VeCG2EAZRQmQNQTyfZkw0Uo+MytAkjj17BXOpY4o6+BToi7rRKfTGl6J60/XBZcGSzN1XVZ80ElSjaGE8Ocg8wbPN18tbmsy761zN5SuIl'
console.log(window.encrypt(public_key,password))
第一步,直接运行,发现错误 ,一开始直接var window=global;
后面发现错误
在控制台打印,发现这个判断就是false,因此采取注释代码的方法,后面发现还有很多类似的问题
因此直接改变策略,改为补充环境。
const{JSDOM} = require('jsdom');
const dom = new JSDOM('<!DOCTYPE html><p> Hello world</p>');
window = dom.window;
navigator = window.navigator;
后面遇到一个问题,直接找到位置,发现刚好是false那部分代码,直接注释,注释代码;
最后结果:
学习一种新的js语法:
encData: function(e, t) {
switch (e.toUpperCase()) {
case "SM2":
return function(e) {
try {
var t = o.generateKeyPairHex()
, n = t.publicKey
, i = e;
o.doEncrypt(i, n, 1)
} catch (e) {}
}(t);
case "SM3":
return function(e) {
try {
var t = a(e);
return t
} catch (e) {}
}(t);
case "SM4":
return function(e) {
try {
for (var t = e.data.data && JSON.stringify(e.data.data), n = "", i = 0; i < t.length; i++) {
var r = t.charAt(i)
, o = t.charCodeAt(i);
n += o > 127 ? "\\u" + o.toString(16).padStart(4, "0") : r
}
var a = A(n);
e.data.appCode && e.data.appCode !== u && (u = e.data.appCode);
var s = y(u, c)
, l = b(s, a);
return l.toUpperCase()
} catch (e) {}
}(t)
}
}("SM4", t)
这段代码看起来是一个 JavaScript 函数,用于对数据进行加密。根据输入的加密算法类型 e
,它会执行相应的加密操作,并返回加密后的结果。
- 当算法类型为 "SM2" 时,它生成一对密钥,并使用公钥对数据进行加密。
- 当算法类型为 "SM3" 时,它对数据进行 SM3 哈希运算。
- 当算法类型为 "SM4" 时,它对数据进行 SM4 加密,首先将数据进行一些格式处理,然后计算密钥和密文,最后返回加密后的结果。
每种情况下,函数都使用了 try-catch 块来捕获可能出现的异常。