qq_36311493 2019-01-08 22:04
浏览 450

这段js的16进制des加解密代码 怎么转换成php?

JsEncryptHelper = {
des: function (n, t, i, r, u) {
var lt = [16843776, 0, 65536, 16843780, 16842756, 66564, 4, 65536, 1024, 16843776, 16843780, 1024, 16778244, 16842756, 16777216, 4, 1028, 16778240, 16778240, 66560, 66560, 16842752, 16842752, 16778244, 65540, 16777220, 16777220, 65540, 0, 1028, 66564, 16777216, 65536, 16843780, 4, 16842752, 16843776, 16777216, 16777216, 1024, 16842756, 65536, 66560, 16777220, 1024, 4, 16778244, 66564, 16843780, 65540, 16842752, 16778244, 16777220, 1028, 66564, 16843776, 1028, 16778240, 16778240, 0, 65540, 66560, 0, 16842756],
ct = [-2146402272, -2147450880, 32768, 1081376, 1048576, 32, -2146435040, -2147450848, -2147483616, -2146402272, -2146402304, -2147483648, -2147450880, 1048576, 32, -2146435040, 1081344, 1048608, -2147450848, 0, -2147483648, 32768, 1081376, -2146435072, 1048608, -2147483616, 0, 1081344, 32800, -2146402304, -2146435072, 32800, 0, 1081376, -2146435040, 1048576, -2147450848, -2146435072, -2146402304, 32768, -2146435072, -2147450880, 32, -2146402272, 1081376, 32, 32768, -2147483648, 32800, -2146402304, 1048576, -2147483616, 1048608, -2147450848, -2147483616, 1048608, 1081344, 0, -2147450880, 32800, -2147483648, -2146435040, -2146402272, 1081344],
at = [520, 134349312, 0, 134348808, 134218240, 0, 131592, 134218240, 131080, 134217736, 134217736, 131072, 134349320, 131080, 134348800, 520, 134217728, 8, 134349312, 512, 131584, 134348800, 134348808, 131592, 134218248, 131584, 131072, 134218248, 8, 134349320, 512, 134217728, 134349312, 134217728, 131080, 520, 131072, 134349312, 134218240, 0, 512, 131080, 134349320, 134218240, 134217736, 512, 0, 134348808, 134218248, 131072, 134217728, 134349320, 8, 131592, 131584, 134217736, 134348800, 134218248, 520, 134348800, 131592, 8, 134348808, 131584],
ft = [8396801, 8321, 8321, 128, 8396928, 8388737, 8388609, 8193, 0, 8396800, 8396800, 8396929, 129, 0, 8388736, 8388609, 1, 8192, 8388608, 8396801, 128, 8388608, 8193, 8320, 8388737, 1, 8320, 8388736, 8192, 8396928, 8396929, 129, 8388736, 8388609, 8396800, 8396929, 129, 0, 0, 8396800, 8320, 8388736, 8388737, 1, 8396801, 8321, 8321, 128, 8396929, 129, 1, 8192, 8388609, 8193, 8396928, 8388737, 8193, 8320, 8388608, 8396801, 128, 8388608, 8192, 8396928],
st = [256, 34078976, 34078720, 1107296512, 524288, 256, 1073741824, 34078720, 1074266368, 524288, 33554688, 1074266368, 1107296512, 1107820544, 524544, 1073741824, 33554432, 1074266112, 1074266112, 0, 1073742080, 1107820800, 1107820800, 33554688, 1107820544, 1073742080, 0, 1107296256, 34078976, 33554432, 1107296256, 524544, 524288, 1107296512, 256, 33554432, 1073741824, 34078720, 1107296512, 1074266368, 33554688, 1073741824, 1107820544, 34078976, 1074266368, 256, 33554432, 1107820544, 1107820800, 524544, 1107296256, 1107820800, 34078720, 0, 1074266112, 1107296256, 524544, 33554688, 1073742080, 524288, 0, 1074266112, 34078976, 1073742080],
ht = [536870928, 541065216, 16384, 541081616, 541065216, 16, 541081616, 4194304, 536887296, 4210704, 4194304, 536870928, 4194320, 536887296, 536870912, 16400, 0, 4194320, 536887312, 16384, 4210688, 536887312, 16, 541065232, 541065232, 0, 4210704, 541081600, 16400, 4210688, 541081600, 536870912, 536887296, 16, 541065232, 4210688, 541081616, 4194304, 16400, 536870928, 4194304, 536887296, 536870912, 16400, 536870928, 541081616, 4210688, 541065216, 4210704, 541081600, 0, 541065232, 16, 16384, 541065216, 4210704, 16384, 4194320, 536887312, 0, 541081600, 536870912, 4194320, 536887312],
et = [2097152, 69206018, 67110914, 0, 2048, 67110914, 2099202, 69208064, 69208066, 2097152, 0, 67108866, 2, 67108864, 69206018, 2050, 67110912, 2099202, 2097154, 67110912, 67108866, 69206016, 69208064, 2097154, 69206016, 2048, 2050, 69208066, 2099200, 2, 67108864, 2099200, 67108864, 2099200, 2097152, 67110914, 67110914, 69206018, 69206018, 2, 2097154, 67108864, 67110912, 2097152, 69208064, 2050, 2099202, 69208064, 2050, 67108866, 69208066, 69206016, 2099200, 0, 2, 69208066, 0, 2099202, 69206016, 2048, 67108866, 67110912, 2048, 2097154],
ot = [268439616, 4096, 262144, 268701760, 268435456, 268439616, 64, 268435456, 262208, 268697600, 268701760, 266240, 268701696, 266304, 4096, 64, 268697600, 268435520, 268439552, 4160, 266240, 262208, 268697664, 268701696, 4160, 0, 0, 268697664, 268435520, 268439552, 266304, 262144, 266304, 262144, 268701696, 4096, 64, 268697664, 4096, 266304, 268439552, 64, 268435520, 268697600, 268697664, 268435456, 262144, 268439616, 0, 268701760, 262208, 268435520, 268697600, 268439552, 268439616, 0, 268701760, 266240, 266240, 4160, 4160, 262208, 268435456, 268701696],
d = JsEncryptHelper.des_createKeys(n),
s = 0,
w,
h,
o,
vt,
p,
a,
e,
f,
v,
y,
nt,
l,
g,
rt,
tt,
ut = t.length,
b = 0,
it = d.length == 32 ? 3 : 9,
k,
c;
for (v = it == 3 ? i ? [0, 32, 2] : [30, -2, -2] : i ? [0, 32, 2, 62, 30, -2, 64, 96, 2] : [94, 62, -2, 32, 64, 2, 30, -2, -2], t += "\x00\x00\x00\x00\x00\x00\x00\x00", k = "", c = "", r == 1 && (y = u.charCodeAt(s++) << 24 | u.charCodeAt(s++) << 16 | u.charCodeAt(s++) << 8 | u.charCodeAt(s++), l = u.charCodeAt(s++) << 24 | u.charCodeAt(s++) << 16 | u.charCodeAt(s++) << 8 | u.charCodeAt(s++), s = 0); s < ut;) {
for (i ? (e = t.charCodeAt(s++) << 16 | t.charCodeAt(s++), f = t.charCodeAt(s++) << 16 | t.charCodeAt(s++)) : (e = t.charCodeAt(s++) << 24 | t.charCodeAt(s++) << 16 | t.charCodeAt(s++) << 8 | t.charCodeAt(s++), f = t.charCodeAt(s++) << 24 | t.charCodeAt(s++) << 16 | t.charCodeAt(s++) << 8 | t.charCodeAt(s++)), r == 1 && (i ? (e ^= y, f ^= l) : (nt = y, g = l, y = e, l = f)), o = (e >>> 4 ^ f) & 252645135, f ^= o, e ^= o << 4, o = (e >>> 16 ^ f) & 65535, f ^= o, e ^= o << 16, o = (f >>> 2 ^ e) & 858993459, e ^= o, f ^= o << 2, o = (f >>> 8 ^ e) & 16711935, e ^= o, f ^= o << 8, o = (e >>> 1 ^ f) & 1431655765, f ^= o, e ^= o << 1, e = e << 1 | e >>> 31, f = f << 1 | f >>> 31, h = 0; h < it; h += 3) {
for (rt = v[h + 1], tt = v[h + 2], w = v[h]; w != rt; w += tt) p = f ^ d[w],
a = (f >>> 4 | f << 28) ^ d[w + 1],
o = e,
e = f,
f = o ^ (ct[p >>> 24 & 63] | ft[p >>> 16 & 63] | ht[p >>> 8 & 63] | ot[p & 63] | lt[a >>> 24 & 63] | at[a >>> 16 & 63] | st[a >>> 8 & 63] | et[a & 63]);
o = e,
e = f,
f = o
}
e = e >>> 1 | e << 31,
f = f >>> 1 | f << 31,
o = (e >>> 1 ^ f) & 1431655765,
f ^= o,
e ^= o << 1,
o = (f >>> 8 ^ e) & 16711935,
e ^= o,
f ^= o << 8,
o = (f >>> 2 ^ e) & 858993459,
e ^= o,
f ^= o << 2,
o = (e >>> 16 ^ f) & 65535,
f ^= o,
e ^= o << 16,
o = (e >>> 4 ^ f) & 252645135,
f ^= o,
e ^= o << 4,
r == 1 && (i ? (y = e, l = f) : (e ^= nt, f ^= g)),
c += i ? String.fromCharCode(e >>> 24, e >>> 16 & 255, e >>> 8 & 255, e & 255, f >>> 24, f >>> 16 & 255, f >>> 8 & 255, f & 255) : String.fromCharCode(e >>> 16 & 65535, e & 65535, f >>> 16 & 65535, f & 65535),
b += i ? 16 : 8,
b == 512 && (k += c, c = "", b = 0)
}
return k + c
},
des_createKeys: function (n) {
for (var tt = [0, 4, 536870912, 536870916, 65536, 65540, 536936448, 536936452, 512, 516, 536871424, 536871428, 66048, 66052, 536936960, 536936964], k = [0, 1, 1048576, 1048577, 67108864, 67108865, 68157440, 68157441, 256, 257, 1048832, 1048833, 67109120, 67109121, 68157696, 68157697], d = [0, 8, 2048, 2056, 16777216, 16777224, 16779264, 16779272, 0, 8, 2048, 2056, 16777216, 16777224, 16779264, 16779272], g = [0, 2097152, 134217728, 136314880, 8192, 2105344, 134225920, 136323072, 131072, 2228224, 134348800, 136445952, 139264, 2236416, 134356992, 136454144], p = [0, 262144, 16, 262160, 0, 262144, 16, 262160, 4096, 266240, 4112, 266256, 4096, 266240, 4112, 266256], w = [0, 1024, 32, 1056, 0, 1024, 32, 1056, 33554432, 33555456, 33554464, 33555488, 33554432, 33555456, 33554464, 33555488], b = [0, 268435456, 524288, 268959744, 2, 268435458, 524290, 268959746, 0, 268435456, 524288, 268959744, 2, 268435458, 524290, 268959746], rt = [0, 65536, 2048, 67584, 536870912, 536936448, 536872960, 536938496, 131072, 196608, 133120, 198656, 537001984, 537067520, 537004032, 537069568], ut = [0, 262144, 0, 262144, 2, 262146, 2, 262146, 33554432, 33816576, 33554432, 33816576, 33554434, 33816578, 33554434, 33816578], ft = [0, 268435456, 8, 268435464, 0, 268435456, 8, 268435464, 1024, 268436480, 1032, 268436488, 1024, 268436480, 1032, 268436488], nt = [0, 32, 0, 32, 1048576, 1048608, 1048576, 1048608, 8192, 8224, 8192, 8224, 1056768, 1056800, 1056768, 1056800], y = [0, 16777216, 512, 16777728, 2097152, 18874368, 2097664, 18874880, 67108864, 83886080, 67109376, 83886592, 69206016, 85983232, 69206528, 85983744], it = [0, 4096, 134217728, 134221824, 524288, 528384, 134742016, 134746112, 16, 4112, 134217744, 134221840, 524304, 528400, 134742032, 134746128], v = [0, 4, 256, 260, 0, 4, 256, 260, 1, 5, 257, 261, 1, 5, 257, 261], a = n.length >= 24 ? 3 : 1, h = new Array(32 * a), c = [0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0], e, o, f = 0, l = 0, u, r, t, s = 0; s < a; s++)
for (r = n.charCodeAt(f++) << 24 | n.charCodeAt(f++) << 16 | n.charCodeAt(f++) << 8 | n.charCodeAt(f++), t = n.charCodeAt(f++) << 24 | n.charCodeAt(f++) << 16 | n.charCodeAt(f++) << 8 | n.charCodeAt(f++), u = (r >>> 4 ^ t) & 252645135, t ^= u, r ^= u << 4, u = (t >>> -16 ^ r) & 65535, r ^= u, t ^= u << -16, u = (r >>> 2 ^ t) & 858993459, t ^= u, r ^= u << 2, u = (t >>> -16 ^ r) & 65535, r ^= u, t ^= u << -16, u = (r >>> 1 ^ t) & 1431655765, t ^= u, r ^= u << 1, u = (t >>> 8 ^ r) & 16711935, r ^= u, t ^= u << 8, u = (r >>> 1 ^ t) & 1431655765, t ^= u, r ^= u << 1, u = r << 8 | t >>> 20 & 240, r = t << 24 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 240, t = u, i = 0; i < c.length; i++) c[i] ? (r = r << 2 | r >>> 26, t = t << 2 | t >>> 26) : (r = r << 1 | r >>> 27, t = t << 1 | t >>> 27),
r &= -15,
t &= -15,
e = tt[r >>> 28] | k[r >>> 24 & 15] | d[r >>> 20 & 15] | g[r >>> 16 & 15] | p[r >>> 12 & 15] | w[r >>> 8 & 15] | b[r >>> 4 & 15],
o = rt[t >>> 28] | ut[t >>> 24 & 15] | ft[t >>> 20 & 15] | nt[t >>> 16 & 15] | y[t >>> 12 & 15] | it[t >>> 8 & 15] | v[t >>> 4 & 15],
u = (o >>> 16 ^ e) & 65535,
h[l++] = e ^ u,
h[l++] = o ^ u << 16;
return h
},
stringToHex: function (n) {
for (var i = "",
r = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"], t = 0; t < n.length; t++) i += r[n.charCodeAt(t) >> 4] + r[n.charCodeAt(t) & 15];
return i
},
hexTostring: function (n) {
for (var r = "",
i, t = 0; t < n.length; t += 2) i = parseInt(n.substring(t, t + 2), 16),
r += String.fromCharCode(i);
return r
},
Encrypt: function (n, t) {
console.log(JsEncryptHelper.des(n, t, 1, 0));
return (t || t == 0 || t == "0" || t == !1 || t == "false") && n && (t = t.toString(), n = n.toString(), (t || t == 0 || t == "0" || t == !1 || t == "false") && n) ? JsEncryptHelper.stringToHex(JsEncryptHelper.des(n, t, 1, 0)) : ""
}
}

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘