哔哩哔哩session生成 js精简版 v=20190111 v=20190311

2080天前 · 分享 · 852次阅读

function session(c) {
    function g(f, e) { 
        f.constructor == String ? f = e && "binary" === e.encoding ? h.uq.Mo(f) : h.bN.Mo(f) : "" ? f = Array.prototype.slice.call(f, 0) : Array.isArray(f) || (f = f.toString());
        e = h.oG(f);
        var l = 8 * f.length;
        f = 1732584193;
        for (var m = -271733879, q = -1732584194, v = 271733878, y = 0; y < e.length; y++)
            e[y] = (e[y] << 8 | e[y] >>> 24) & 16711935 | (e[y] << 24 | e[y] >>> 8) & 4278255360;
        e[l >>> 5] |= 128 << l % 32;
        e[(l + 64 >>> 9 << 4) + 14] = l; 
        for (var l = g.OE, u = g.bF, B = g.cF, A = g.fF, y = 0; y < e.length; y += 16) {
            var z = f,
            C = m,
            n = q,
            t = v;
            f = l(f, m, q, v, e[y + 0], 7, -680876936);
            v = l(v, f, m, q, e[y + 1], 12, -389564586);
            q = l(q, v, f, m, e[y + 2], 17, 606105819);
            m = l(m, q, v, f, e[y + 3], 22, -1044525330);
            f = l(f, m, q, v, e[y + 4], 7, -176418897);
            v = l(v, f, m, q, e[y + 5], 12, 1200080426);
            q = l(q, v, f, m, e[y + 6], 17, -1473231341);
            m = l(m, q, v, f, e[y + 7], 22, -45705983);
            f = l(f, m, q, v, e[y + 8], 7, 1770035416);
            v = l(v, f, m, q, e[y + 9], 12, -1958414417);
            q = l(q, v, f, m, e[y + 10], 17, -42063);
            m = l(m, q, v, f, e[y + 11], 22, -1990404162);
            f = l(f, m, q, v, e[y + 12], 7, 1804603682);
            v = l(v, f, m, q, e[y + 13], 12, -40341101);
            q = l(q, v, f, m, e[y + 14], 17, -1502002290);
            m = l(m, q, v, f, e[y + 15], 22, 1236535329);
            f = u(f, m, q, v, e[y + 1], 5, -165796510);
            v = u(v, f, m, q, e[y + 6], 9, -1069501632);
            q = u(q, v, f, m, e[y + 11], 14, 643717713);
            m = u(m, q, v, f, e[y + 0], 20, -373897302);
            f = u(f, m, q, v, e[y + 5], 5, -701558691);
            v = u(v, f, m, q, e[y + 10], 9, 38016083);
            q = u(q, v, f, m, e[y + 15], 14, -660478335);
            m = u(m, q, v, f, e[y + 4], 20, -405537848);
            f = u(f, m, q, v, e[y + 9], 5, 568446438);
            v = u(v, f, m, q, e[y + 14], 9, -1019803690);
            q = u(q, v, f, m, e[y + 3], 14, -187363961);
            m = u(m, q, v, f, e[y + 8], 20, 1163531501);
            f = u(f, m, q, v, e[y + 13], 5, -1444681467);
            v = u(v, f, m, q, e[y + 2], 9, -51403784);
            q = u(q, v, f, m, e[y + 7], 14, 1735328473);
            m = u(m, q, v, f, e[y + 12], 20, -1926607734);
            f = B(f, m, q, v, e[y + 5], 4, -378558);
            v = B(v, f, m, q, e[y + 8], 11, -2022574463);
            q = B(q, v, f, m, e[y + 11], 16, 1839030562);
            m = B(m, q, v, f, e[y + 14], 23, -35309556);
            f = B(f, m, q, v, e[y + 1], 4, -1530992060);
            v = B(v, f, m, q, e[y + 4], 11, 1272893353);
            q = B(q, v, f, m, e[y + 7], 16, -155497632);
            m = B(m, q, v, f, e[y + 10], 23, -1094730640);
            f = B(f, m, q, v, e[y + 13], 4, 681279174);
            v = B(v, f, m, q, e[y + 0], 11, -358537222);
            q = B(q, v, f, m, e[y + 3], 16, -722521979);
            m = B(m, q, v, f, e[y + 6], 23, 76029189);
            f = B(f, m, q, v, e[y + 9], 4, -640364487);
            v = B(v, f, m, q, e[y + 12], 11, -421815835);
            q = B(q, v, f, m, e[y + 15], 16, 530742520);
            m = B(m, q, v, f, e[y + 2], 23, -995338651);
            f = A(f, m, q, v, e[y + 0], 6, -198630844);
            v = A(v, f, m, q, e[y + 7], 10, 1126891415);
            q = A(q, v, f, m, e[y + 14], 15, -1416354905);
            m = A(m, q, v, f, e[y + 5], 21, -57434055);
            f = A(f, m, q, v, e[y + 12], 6, 1700485571);
            v = A(v, f, m, q, e[y + 3], 10, -1894986606);
            q = A(q, v, f, m, e[y + 10], 15, -1051523);
            m = A(m, q, v, f, e[y + 1], 21, -2054922799);
            f = A(f, m, q, v, e[y + 8], 6, 1873313359);
            v = A(v, f, m, q, e[y + 15], 10, -30611744);
            q = A(q, v, f, m, e[y + 6], 15, -1560198380);
            m = A(m, q, v, f, e[y + 13], 21, 1309151649);
            f = A(f, m, q, v, e[y + 4], 6, -145523070);
            v = A(v, f, m, q, e[y + 11], 10, -1120210379);
            q = A(q, v, f, m, e[y + 2], 15, 718787259);
            m = A(m, q, v, f, e[y + 9], 21, -343485551);
            f = f + z >>> 0;
            m = m + C >>> 0;
            q = q + n >>> 0;
            v = v + t >>> 0
        }
        return h.Wx([f, m, q, v])
    }
    var h = {
        oG: function (e) {
            for (var g = [], h = 0, d = 0; h < e.length; h++,
                d += 8)
                g[d >>> 5] |= e[h] << 24 - d % 32;
            return g
        },
        zN: function (e) {
            for (var g = [], h = 0; h < 32 * e.length; h += 8)
                g.push(e[h >>> 5] >>> 24 - h % 32 & 255);
            return g
        },
        nG: function (e) {
            for (var g = [], h = 0; h < e.length; h++)
                g.push((e[h] >>> 4).toString(16)),
                g.push((e[h] & 15).toString(16));
            return g.join("")
        },
        Wx: function (e) {
            if (e.constructor == Number)
                return h.vA(e, 8) & 16711935 | h.vA(e, 24) & 4278255360;
            for (var g = 0; g < e.length; g++)
                e[g] = h.Wx(e[g]);
            return e
        },
        vA: function (e, g) {
            return e << g | e >>> 32 - g
        },
        bN: {
            Mo: function (e) {
                return h.uq.Mo(unescape(encodeURIComponent(e)))
            },
            yq: function (e) {
                return decodeURIComponent(escape(h.uq.yq(e)))
            }
        },
        uq: {
            Mo: function (e) {
                for (var g = [], h = 0; h < e.length; h++)
                    g.push(e.charCodeAt(h) & 255);
                return g
            },
            yq: function (e) {
                for (var g = [], h = 0; h < e.length; h++)
                    g.push(String.fromCharCode(e[h]));
                return g.join("")
            }
        }
    };
    g.OE = function (b, c, d, e, q, h, g) {
        b = b + (c & d | ~c & e) + (q >>> 0) + g;
        return (b << h | b >>> 32 - h) + c
    };
    g.bF = function (b, c, d, e, q, h, g) {
        b = b + (c & e | d & ~e) + (q >>> 0) + g;
        return (b << h | b >>> 32 - h) + c
    };
    g.cF = function (b, c, d, e, q, h, g) {
        b = b + (c ^ d ^ e) + (q >>> 0) + g;
        return (b << h | b >>> 32 - h) + c
    };
    g.fF = function (b, c, d, e, q, h, g) {
        b = b + (d ^ (c | ~e)) + (q >>> 0) + g;
        return (b << h | b >>> 32 - h) + c
    };
    var d;
    g.PO = 16;
    g.QO = 16;
    c = h.zN(g(c, d)); 
    session = h.nG(c); 
    return session
}

调用方法

buvid3 = "";
c = String(buvid3 || Math.floor(1E5 * Math.random()).toString(16)) + +new Date
console.log(session(c))

其中buvid3为cookie中的值,不登录则为空

v=20190311 这个版本运行结果是一样的,代码的命名?稍微有一点变化

function session(c) {
    function g(t, n, g) {
        var d = g.ff, f = g.gg, c = g.hh, h = g.ii;
        t.constructor == String ? t = n && "binary" === n.encoding ? v.bin.stringToBytes(t) : v.utf8.stringToBytes(t) : v.gettype(t) ? t = Array.prototype.slice.call(t, 0) : Array.isArray(t) || (t = t.toString());
        for (var r = v.bytesToWords(t), i = 8 * t.length, a = 1732584193, o = -271733879, s = -1732584194, u = 271733878, l = 0; l < r.length; l++)
            r[l] = 16711935 & (r[l] << 8 | r[l] >>> 24) | 4278255360 & (r[l] << 24 | r[l] >>> 8);
        r[i >>> 5] |= 128 << i % 32;
        r[14 + (i + 64 >>> 9 << 4)] = i;
        for (l = 0; l < r.length; l += 16) {
            var p = a,
            g = o,
            m = s,
            _ = u;
            a = d(a, o, s, u, r[l + 0], 7, -680876936),
            u = d(u, a, o, s, r[l + 1], 12, -389564586),
            s = d(s, u, a, o, r[l + 2], 17, 606105819),
            o = d(o, s, u, a, r[l + 3], 22, -1044525330),
            a = d(a, o, s, u, r[l + 4], 7, -176418897),
            u = d(u, a, o, s, r[l + 5], 12, 1200080426),
            s = d(s, u, a, o, r[l + 6], 17, -1473231341),
            o = d(o, s, u, a, r[l + 7], 22, -45705983),
            a = d(a, o, s, u, r[l + 8], 7, 1770035416),
            u = d(u, a, o, s, r[l + 9], 12, -1958414417),
            s = d(s, u, a, o, r[l + 10], 17, -42063),
            o = d(o, s, u, a, r[l + 11], 22, -1990404162),
            a = d(a, o, s, u, r[l + 12], 7, 1804603682),
            u = d(u, a, o, s, r[l + 13], 12, -40341101),
            s = d(s, u, a, o, r[l + 14], 17, -1502002290),
            o = d(o, s, u, a, r[l + 15], 22, 1236535329),
            a = f(a, o, s, u, r[l + 1], 5, -165796510),
            u = f(u, a, o, s, r[l + 6], 9, -1069501632),
            s = f(s, u, a, o, r[l + 11], 14, 643717713),
            o = f(o, s, u, a, r[l + 0], 20, -373897302),
            a = f(a, o, s, u, r[l + 5], 5, -701558691),
            u = f(u, a, o, s, r[l + 10], 9, 38016083),
            s = f(s, u, a, o, r[l + 15], 14, -660478335),
            o = f(o, s, u, a, r[l + 4], 20, -405537848),
            a = f(a, o, s, u, r[l + 9], 5, 568446438),
            u = f(u, a, o, s, r[l + 14], 9, -1019803690),
            s = f(s, u, a, o, r[l + 3], 14, -187363961),
            o = f(o, s, u, a, r[l + 8], 20, 1163531501),
            a = f(a, o, s, u, r[l + 13], 5, -1444681467),
            u = f(u, a, o, s, r[l + 2], 9, -51403784),
            s = f(s, u, a, o, r[l + 7], 14, 1735328473),
            o = f(o, s, u, a, r[l + 12], 20, -1926607734),
            a = c(a, o, s, u, r[l + 5], 4, -378558),
            u = c(u, a, o, s, r[l + 8], 11, -2022574463),
            s = c(s, u, a, o, r[l + 11], 16, 1839030562),
            o = c(o, s, u, a, r[l + 14], 23, -35309556),
            a = c(a, o, s, u, r[l + 1], 4, -1530992060),
            u = c(u, a, o, s, r[l + 4], 11, 1272893353),
            s = c(s, u, a, o, r[l + 7], 16, -155497632),
            o = c(o, s, u, a, r[l + 10], 23, -1094730640),
            a = c(a, o, s, u, r[l + 13], 4, 681279174),
            u = c(u, a, o, s, r[l + 0], 11, -358537222),
            s = c(s, u, a, o, r[l + 3], 16, -722521979),
            o = c(o, s, u, a, r[l + 6], 23, 76029189),
            a = c(a, o, s, u, r[l + 9], 4, -640364487),
            u = c(u, a, o, s, r[l + 12], 11, -421815835),
            s = c(s, u, a, o, r[l + 15], 16, 530742520),
            o = c(o, s, u, a, r[l + 2], 23, -995338651),
            a = h(a, o, s, u, r[l + 0], 6, -198630844),
            u = h(u, a, o, s, r[l + 7], 10, 1126891415),
            s = h(s, u, a, o, r[l + 14], 15, -1416354905),
            o = h(o, s, u, a, r[l + 5], 21, -57434055),
            a = h(a, o, s, u, r[l + 12], 6, 1700485571),
            u = h(u, a, o, s, r[l + 3], 10, -1894986606),
            s = h(s, u, a, o, r[l + 10], 15, -1051523),
            o = h(o, s, u, a, r[l + 1], 21, -2054922799),
            a = h(a, o, s, u, r[l + 8], 6, 1873313359),
            u = h(u, a, o, s, r[l + 15], 10, -30611744),
            s = h(s, u, a, o, r[l + 6], 15, -1560198380),
            o = h(o, s, u, a, r[l + 13], 21, 1309151649),
            a = h(a, o, s, u, r[l + 4], 6, -145523070),
            u = h(u, a, o, s, r[l + 11], 10, -1120210379),
            s = h(s, u, a, o, r[l + 2], 15, 718787259),
            o = h(o, s, u, a, r[l + 9], 21, -343485551),
            a = a + p >>> 0,
            o = o + g >>> 0,
            s = s + m >>> 0,
            u = u + _ >>> 0
        }
        return v.endian([a, o, s, u])
    }
    var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    var v = {
        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 & v.rotl(e, 8) | 4278255360 & v.rotl(e, 24);
            for (var t = 0; t < e.length; t++)
                e[t] = v.endian(e[t]);
            return e
        },
        randomBytes: function (e) {
            for (var t = []; 0 < e; 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 t = [], n = 0; n < e.length; n += 3)
                for (var r = e[n] << 16 | e[n + 1] << 8 | e[n + 2], i = 0; i < 4; i++)
                    8 * n + 6 * i <= 8 * e.length ? t.push(a.charAt(r >>> 6 * (3 - i) & 63)) : t.push("=");
            return t.join("")
        },
        base64ToBytes: function (e) {
            e = e.replace(/[^A-Z0-9+\/]/gi, "");
            for (var t = [], n = 0, r = 0; n < e.length; r = ++n % 4)
                0 != r && t.push((a.indexOf(e.charAt(n - 1)) & Math.pow(2, -2 * r + 8) - 1) << 2 * r | a.indexOf(e.charAt(n)) >>> 6 - 2 * r);
            return t
        },
        gettype: function (e, t) {
            function n(e) {
                return !!e.constructor && "function" == typeof e.constructor.isBuffer && e.constructor.isBuffer(e)
            }
            e.exports = function (e) {
                return null != e && (n(e) || (t = e,
                        "function" == typeof t.readFloatLE && "function" == typeof t.slice && n(t.slice(0, 0))) || !!e._isBuffer);
                var t
            }
        },
        utf8: {
            stringToBytes: function (e) {
                return v.bin.stringToBytes(unescape(encodeURIComponent(e)))
            },
            bytesToString: function (e) {
                return decodeURIComponent(escape(v.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("")
            }
        }
    };
    g.ff = function (e, t, n, r, i, a, o) {
        var s = e + (t & n | ~t & r) + (i >>> 0) + o;
        return (s << a | s >>> 32 - a) + t
    };
    g.gg = function (e, t, n, r, i, a, o) {
        var s = e + (t & r | n & ~r) + (i >>> 0) + o;
        return (s << a | s >>> 32 - a) + t
    };
    g.hh = function (e, t, n, r, i, a, o) {
        var s = e + (t ^ n ^ r) + (i >>> 0) + o;
        return (s << a | s >>> 32 - a) + t
    };
    g.ii = function (e, t, n, r, i, a, o) {
        var s = e + (n ^ (t | ~r)) + (i >>> 0) + o;
        return (s << a | s >>> 32 - a) + t
    };

    var t, n;
    g._blocksize = 16;
    g._digestsize = 16;
    n = v.wordsToBytes(g(c, t, g));
    return t && t.asBytes ? n : t && t.asString ? v.bin.bytesToString(n) : v.bytesToHex(n)

}
// aa4603710244eb68d20192a82aa89904
c = "7C62EBC1-E843-47C6-9025-CC3665A0A6C1101596infoc1552459932619";
console.log(session(c))
👍 0

哔哩哔哩

最后修改于1566天前

评论

贴吧 狗头 原神 小黄脸
收起

贴吧

狗头

原神

小黄脸

目录

avatar

未末

迷失

126

文章数

275

评论数

7

分类