window.tdxEncrypt = function(r) {
if (0 === r.indexOf("@ec0"))
return r;
r = e.encrypt(r += "@_bfstr");
return "@ec0:" + e.base64Encode(r)
}
再继续定位到e.encrypt函数代码:
[JavaScript] 纯文本查看复制代码
encrypt: function(r, t) {
if ("ecb" === this.mode)
return this.encryptECB(r);
if ("cbc" === this.mode)
return this.encryptCBC(r, t);
throw new Error("Неизвестный режим шифрования.")
},
通过打断点进去,可以看见,this.mode=ecb,因此手机号是encryptECB加密函数:
[JavaScript] 纯文本查看复制代码
encryptECB: function(r) {
r = this.utf8Decode(r);
for (var t = Math.ceil(r.length / 8), o = "", e = 0; e < t; e++) {
var n = r.substr(8 * e, 8);
if (n.length < 8)
for (var i = 8 - n.length; 0 < i--; )
n += "\0";
var h = this.split64by32(n)
, s = h[0]
, u = h[1];
s = (h = this.encipherEX(s, u))[0],
u = h[1],
o += this.num2block32(u) + this.num2block32(s)
}
return o
},
再把涉及到的一些调用函数抠出来:
[JavaScript] 纯文本查看复制代码
split64by32: function(r) {
var t = r.substring(0, 4)
, r = r.substring(4, 8);
return [this.block32toNum(t), this.block32toNum(r)]
},
utf8Decode: function(r) {
for (var t = "", o = 0; o < r.length; o++) {
var e = r.charCodeAt(o);
e < 128 ? t += String.fromCharCode(e) : (127 < e && e < 2048 ? t += String.fromCharCode(e >> 6 | 192) : (t += String.fromCharCode(e >> 12 | 224),
t += String.fromCharCode(e >> 6 & 63 | 128)),
t += String.fromCharCode(63 & e | 128))
}
return t
},
encipherEX: function(r, t) {
var o = this
, t = t
, r = o.xor(r = r, o.pArray[0])
, t = o.round(t, r, 1);
return r = o.round(r, t, 2),
t = o.round(t, r, 3),
r = o.round(r, t, 4),
t = o.round(t, r, 5),
r = o.round(r, t, 6),
t = o.round(t, r, 7),
r = o.round(r, t, 8),
t = o.round(t, r, 9),
r = o.round(r, t, 10),
t = o.round(t, r, 11),
r = o.round(r, t, 12),
t = o.round(t, r, 13),
r = o.round(r, t, 14),
t = o.round(t, r, 15),
[r = o.round(r, t, 16), t = o.xor(t, o.pArray[17])]
},
xor: function(r, t) {
return this.fixNegative(r ^ t)
},
trimZeros: function(r) {
return r.replace(/\0+$/g, "")
},
wordbyte0: function(r) {
return Math.floor(Math.floor(Math.floor(r / 256) / 256) / 256) % 256
},
wordbyte1: function(r) {
return Math.floor(Math.floor(r / 256) / 256) % 256
},
wordbyte2: function(r) {
return Math.floor(r / 256) % 256
},
wordbyte3: function(r) {
return r % 256
},
round: function(r, t, o) {
var e = this;
return e.xor(r, e.xor(e.xor(e.sBox0[e.wordbyte0(t)] + e.sBox1[e.wordbyte1(t)], e.sBox2[e.wordbyte2(t)]) + e.sBox3[e.wordbyte3(t)], e.pArray[o]))
},
o对象的值:
{
"key": "w83c5~%%30nm5-+",
"sBox0": [
1401335157,
2656414153,
1572114622,
这里还有,省略掉,太长了,
839348932,
2117317013,
1753590868
],
"sBox1": [
2944530774,
611268753,
2480642903,
这里还有,省略掉,太长了,
1125867267
],
"sBox2": [
117595124,
794470125,
1939519107,
这里还有,省略掉,太长了,
1016397799,
2504754504
],
"sBox3": [
898774924,
这里还有,省略掉,太长了,
35895393,
1829467942
],
"pArray": [
4293367326,
2903747409,
这里还有,省略掉,太长了,
1985119492
]
}
num2block32: function(r) {
return String.fromCharCode(r << 24 >>> 24) + String.fromCharCode(r << 16 >>> 24) + String.fromCharCode(r << 8 >>> 24) + String.fromCharCode(r >>> 24)
},
block32toNum: function(r) {
return this.fixNegative(r.charCodeAt(3) << 24 | r.charCodeAt(2) << 16 | r.charCodeAt(1) << 8 | r.charCodeAt(0))
},
fixNegative: function(r) {
return r >>> 0
},
base64Encode: function(r) {
for (var t, o, e, n, i, h, s = "", u = 0; u < r.length; )
e = (h = r.charCodeAt(u++)) >> 2,
n = (3 & h) << 4 | (t = r.charCodeAt(u++)) >> 4,
i = (15 & t) << 2 | (o = r.charCodeAt(u++)) >> 6,
h = 63 & o,
isNaN(t) ? i = h = 64 : isNaN(o) && (h = 64),
s = s + this.keyStr.charAt(e) + this.keyStr.charAt(n) + this.keyStr.charAt(i) + this.keyStr.charAt(h);
return s
},
keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",