V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
douleL
V2EX  ›  Java

这段 js 代码 Java 应该怎么写 有大佬解读下吗

  •  
  •   douleL · 2021-04-08 17:15:04 +08:00 · 1513 次点击
    这是一个创建于 1325 天前的主题,其中的信息可能已经有所发展或是发生改变。
    function sign(t, n) {
    var o = [];
    for (var r in t) o.push("".concat(r, "=").concat(t[r]));
    var a = "".concat(o.join("&")).concat("xxxxxxx");
    return n && (a = "".concat(a).concat(JSON.stringify(n))),
    a = a.replace(/a/gm, "c")
    .replace(/e/gm, "g")
    .replace(new RegExp(" ", "gm"), ""),
    (0, _default)(a);
    }

    function __default(n1, r1, t1) {
    if (!r1) return t1 ? l(n1) : a(l(n1));
    if (!t1) return a(g(r1, n1));
    return g(r1, n1);

    function n(n, r) {
    var t = (65535 & n) + (65535 & r);
    return (n >> 16) + (r >> 16) + (t >> 16) << 16 | 65535 & t;
    }

    function r(r, t, e, u, o, c) {
    return n((f = n(n(t, r), n(u, c))) << (i = o) | f >>> 32 - i, e);
    var f, i;
    }

    function t(n, t, e, u, o, c, f) {
    return r(t & e | ~t & u, n, t, o, c, f);
    }

    function e(n, t, e, u, o, c, f) {
    return r(t & u | e & ~u, n, t, o, c, f);
    }

    function u(n, t, e, u, o, c, f) {
    return r(t ^ e ^ u, n, t, o, c, f);
    }

    function o(n, t, e, u, o, c, f) {
    return r(e ^ (t | ~u), n, t, o, c, f);
    }

    function c(r, c) {
    r[c >> 5] |= 128 << c % 32, r[14 + (c + 64 >>> 9 << 4)] = c;
    var f, i, a, h, l, g = 1732584193, v = -271733879, d = -1732584194, C = 271733878;
    for (f = 0; f < r.length; f += 16) i = g, a = v, h = d, l = C, g = t(g, v, d, C, r[f], 7, -680876936),
    C = t(C, g, v, d, r[f + 1], 12, -389564586), d = t(d, C, g, v, r[f + 2], 17, 606105819),
    v = t(v, d, C, g, r[f + 3], 22, -1044525330), g = t(g, v, d, C, r[f + 4], 7, -176418897),
    C = t(C, g, v, d, r[f + 5], 12, 1200080426), d = t(d, C, g, v, r[f + 6], 17, -1473231341),
    v = t(v, d, C, g, r[f + 7], 22, -45705983), g = t(g, v, d, C, r[f + 8], 7, 1770035416),
    C = t(C, g, v, d, r[f + 9], 12, -1958414417), d = t(d, C, g, v, r[f + 10], 17, -42063),
    v = t(v, d, C, g, r[f + 11], 22, -1990404162), g = t(g, v, d, C, r[f + 12], 7, 1804603682),
    C = t(C, g, v, d, r[f + 13], 12, -40341101), d = t(d, C, g, v, r[f + 14], 17, -1502002290),
    g = e(g, v = t(v, d, C, g, r[f + 15], 22, 1236535329), d, C, r[f + 1], 5, -165796510),
    C = e(C, g, v, d, r[f + 6], 9, -1069501632), d = e(d, C, g, v, r[f + 11], 14, 643717713),
    v = e(v, d, C, g, r[f], 20, -373897302), g = e(g, v, d, C, r[f + 5], 5, -701558691),
    C = e(C, g, v, d, r[f + 10], 9, 38016083), d = e(d, C, g, v, r[f + 15], 14, -660478335),
    v = e(v, d, C, g, r[f + 4], 20, -405537848), g = e(g, v, d, C, r[f + 9], 5, 568446438),
    C = e(C, g, v, d, r[f + 14], 9, -1019803690), d = e(d, C, g, v, r[f + 3], 14, -187363961),
    v = e(v, d, C, g, r[f + 8], 20, 1163531501), g = e(g, v, d, C, r[f + 13], 5, -1444681467),
    C = e(C, g, v, d, r[f + 2], 9, -51403784), d = e(d, C, g, v, r[f + 7], 14, 1735328473),
    g = u(g, v = e(v, d, C, g, r[f + 12], 20, -1926607734), d, C, r[f + 5], 4, -378558),
    C = u(C, g, v, d, r[f + 8], 11, -2022574463), d = u(d, C, g, v, r[f + 11], 16, 1839030562),
    v = u(v, d, C, g, r[f + 14], 23, -35309556), g = u(g, v, d, C, r[f + 1], 4, -1530992060),
    C = u(C, g, v, d, r[f + 4], 11, 1272893353), d = u(d, C, g, v, r[f + 7], 16, -155497632),
    v = u(v, d, C, g, r[f + 10], 23, -1094730640), g = u(g, v, d, C, r[f + 13], 4, 681279174),
    C = u(C, g, v, d, r[f], 11, -358537222), d = u(d, C, g, v, r[f + 3], 16, -722521979),
    v = u(v, d, C, g, r[f + 6], 23, 76029189), g = u(g, v, d, C, r[f + 9], 4, -640364487),
    C = u(C, g, v, d, r[f + 12], 11, -421815835), d = u(d, C, g, v, r[f + 15], 16, 530742520),
    g = o(g, v = u(v, d, C, g, r[f + 2], 23, -995338651), d, C, r[f], 6, -198630844),
    C = o(C, g, v, d, r[f + 7], 10, 1126891415), d = o(d, C, g, v, r[f + 14], 15, -1416354905),
    v = o(v, d, C, g, r[f + 5], 21, -57434055), g = o(g, v, d, C, r[f + 12], 6, 1700485571),
    C = o(C, g, v, d, r[f + 3], 10, -1894986606), d = o(d, C, g, v, r[f + 10], 15, -1051523),
    v = o(v, d, C, g, r[f + 1], 21, -2054922799), g = o(g, v, d, C, r[f + 8], 6, 1873313359),
    C = o(C, g, v, d, r[f + 15], 10, -30611744), d = o(d, C, g, v, r[f + 6], 15, -1560198380),
    v = o(v, d, C, g, r[f + 13], 21, 1309151649), g = o(g, v, d, C, r[f + 4], 6, -145523070),
    C = o(C, g, v, d, r[f + 11], 10, -1120210379), d = o(d, C, g, v, r[f + 2], 15, 718787259),
    v = o(v, d, C, g, r[f + 9], 21, -343485551), g = n(g, i), v = n(v, a), d = n(d, h),
    C = n(C, l);
    return [ g, v, d, C ];
    }

    function f(n) {
    var r, t = "";
    for (r = 0; r < 32 * n.length; r += 8) t += String.fromCharCode(n[r >> 5] >>> r % 32 & 255);
    return t;
    }

    function i(n) {
    var r, t = [];
    for (t[(n.length >> 2) - 1] = void 0, r = 0; r < t.length; r += 1) t[r] = 0;
    for (r = 0; r < 8 * n.length; r += 8) t[r >> 5] |= (255 & n.charCodeAt(r / 8)) << r % 32;
    return t;
    }

    function a(n) {
    var r, t, e = "";
    for (t = 0; t < n.length; t += 1) r = n.charCodeAt(t), e += "0123456789ABCDEF".charAt(r >>> 4 & 15) + "0123456789ABCDEF".charAt(15 & r);
    return e;
    }

    function h(n) {
    return unescape(encodeURIComponent(n));
    }

    function l(n) {
    return function(n) {
    return f(c(i(n), 8 * n.length));
    }(h(n));
    }

    function g(n, r) {
    return function(n, r) {
    var t, e, u = i(n), o = [], a = [];
    for (o[15] = a[15] = void 0, u.length > 16 && (u = c(u, 8 * n.length)), t = 0; t < 16; t += 1) o[t] = 909522486 ^ u[t],
    a[t] = 1549556828 ^ u[t];
    return e = c(o.concat(i(r)), 512 + 8 * r.length), f(c(a.concat(e), 640));
    }(h(n), h(r));
    }

    }
    ming168
        1
    ming168  
       2021-04-08 17:20:33 +08:00
    这排版看着就头痛
    zhizunzz
        2
    zhizunzz  
       2021-04-08 17:22:46 +08:00
    我觉得大佬不会帮这样的忙
    lepig
        3
    lepig  
       2021-04-08 17:23:01 +08:00
    这排版我看都不想看,虽然我也不会
    yamedie
        4
    yamedie  
       2021-04-08 17:25:47 +08:00
    这跟排版没太大关系, 主要是 js 经过了混淆, 方法名跟局部变量混在一起这谁能看得懂
    paccco
        5
    paccco  
       2021-04-08 17:26:01 +08:00
    你需要先学习 MD 语法
    jimliang
        6
    jimliang  
       2021-04-08 17:26:01 +08:00
    要不直接找个 js 引擎直接调得了
    zhuweiyou
        7
    zhuweiyou  
       2021-04-08 17:27:19 +08:00
    ScriptEngineManager 了解一下
    mx8Y3o5w3M70LC4y
        8
    mx8Y3o5w3M70LC4y  
       2021-04-08 17:28:03 +08:00 via Android
    笑死我了
    redtea
        9
    redtea  
       2021-04-08 17:34:36 +08:00
    看起来像 MD5 的算法
    Sunyanzi
        10
    Sunyanzi  
       2021-04-08 17:55:08 +08:00   ❤️ 1
    看着代码多但其实挺简单的 ... 只有 sign 需要看 ... 调用 __default 的时候只给了 n1 ... r1 t1 都没传 ...

    所以实际上从 __default 开始的一堆代码只是实现了一个标准的 MD5 ... 对 sign 构造的字符串做了个摘要 ...

    而 sign 实现的功能就是构造了类似 queryString 的字符串再拼上个 xxx ... 确实没啥难度 ...
    xiayue
        11
    xiayue  
       2021-04-09 10:47:26 +08:00
    老哥,你这是经过混淆的代码,找源码看吧。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2021 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 00:55 · PVG 08:55 · LAX 16:55 · JFK 19:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.