js rsa

发布时间 2023-10-27 16:20:46作者: AngDH
$0=undefined;



var py = "0123456789abcdefghijklmnopqrstuvwxyz";
function v0(t) {
    return py.charAt(t)
}
function hy(t, e) {
    return t & e
}
function vs(t, e) {
    return t | e
}
function xc(t, e) {
    return t ^ e
}
function wc(t, e) {
    return t & ~e
}
function vy(t) {
    if (t == 0)
        return -1;
    var e = 0;
    return t & 65535 || (t >>= 16,
    e += 16),
    t & 255 || (t >>= 8,
    e += 8),
    t & 15 || (t >>= 4,
    e += 4),
    t & 3 || (t >>= 2,
    e += 2),
    t & 1 || ++e,
    e
}
function gy(t) {
    for (var e = 0; t != 0; )
        t &= t - 1,
        ++e;
    return e
};


var Tc = function() {
    function t(e) {
        this.m = e,
        this.mp = e.invDigit(),
        this.mpl = this.mp & 32767,
        this.mph = this.mp >> 15,
        this.um = (1 << e.DB - 15) - 1,
        this.mt2 = 2 * e.t
    }
    return t.prototype.convert = function(e) {
        var r = Me();
        return e.abs().dlShiftTo(this.m.t, r),
        r.divRemTo(this.m, null, r),
        e.s < 0 && r.compareTo(Ce.ZERO) > 0 && this.m.subTo(r, r),
        r
    }
    ,
    t.prototype.revert = function(e) {
        var r = Me();
        return e.copyTo(r),
        this.reduce(r),
        r
    }
    ,
    t.prototype.reduce = function(e) {
        for (; e.t <= this.mt2; )
            e[e.t++] = 0;
        for (var r = 0; r < this.m.t; ++r) {
            var n = e[r] & 32767
              , s = n * this.mpl + ((n * this.mph + (e[r] >> 15) * this.mpl & this.um) << 15) & e.DM;
            for (n = r + this.m.t,
            e[n] += this.m.am(0, s, e, r, 0, this.m.t); e[n] >= e.DV; )
                e[n] -= e.DV,
                e[++n]++
        }
        e.clamp(),
        e.drShiftTo(this.m.t, e),
        e.compareTo(this.m) >= 0 && e.subTo(this.m, e)
    }
    ,
    t.prototype.mulTo = function(e, r, n) {
        e.multiplyTo(r, n),
        this.reduce(n)
    }
    ,
    t.prototype.sqrTo = function(e, r) {
        e.squareTo(r),
        this.reduce(r)
    }
    ,
    t
}();


function getRandomValues(arr) {
    for (var i = 0; i < arr.length; i++) {
    arr[i] = Math.floor(Math.random() * 256);
  }
}





var Sy = function() {
    function t() {
        this.i = 0,
        this.j = 0,
        this.S = []
    }
    return t.prototype.init = function(e) {
        var r, n, s;
        for (r = 0; r < 256; ++r)
            this.S[r] = r;
        for (n = 0,
        r = 0; r < 256; ++r)
            n = n + this.S[r] + e[r % e.length] & 255,
            s = this.S[r],
            this.S[r] = this.S[n],
            this.S[n] = s;
        this.i = 0,
        this.j = 0
    }
    ,
    t.prototype.next = function() {
        var e;
        return this.i = this.i + 1 & 255,
        this.j = this.j + this.S[this.i] & 255,
        e = this.S[this.i],
        this.S[this.i] = this.S[this.j],
        this.S[this.j] = e,
        this.S[e + this.S[this.i] & 255]
    }
    ,
    t
}();
function Ty() {
    return new Sy
}

var Pd = 256, ms, R0 = null, Kt;
if (R0 == null) {
    R0 = [],
    Kt = 0;
    var ys = void 0;
    if (true) {
        var ra = new Uint32Array(256);
        for (getRandomValues(ra),
        ys = 0; ys < ra.length; ++ys)
            R0[Kt++] = ra[ys] & 255
    }

};

function By() {
    if (ms == null) {
        for (ms = Ty(); Kt < Pd; ) {
            var t = Math.floor(65536 * Math.random());
            R0[Kt++] = t & 255
        }
        for (ms.init(R0),
        Kt = 0; Kt < R0.length; ++Kt)
            R0[Kt] = 0;
        Kt = 0
    }
    return ms.next()
}

var ko = function() {
    function t() {}
    return t.prototype.nextBytes = function(e) {
        for (var r = 0; r < e.length; ++r)
            e[r] = By()
    }
    ,
    t
}();
function My(t, e) {
    if (e < t.length + 22)
        return console.error("Message too long for RSA"),
        null;
    for (var r = e - t.length - 6, n = "", s = 0; s < r; s += 2)
        n += "ff";
    var i = "0001" + n + "00" + t;
    return Ke(i, 16)
}
function zy(t, e) {
    if (e < t.length + 11)
        return console.error("Message too long for RSA"),
        null;
    for (var r = [], n = t.length - 1; n >= 0 && e > 0; ) {
        var s = t.charCodeAt(n--);
        s < 128 ? r[--e] = s : s > 127 && s < 2048 ? (r[--e] = s & 63 | 128,
        r[--e] = s >> 6 | 192) : (r[--e] = s & 63 | 128,
        r[--e] = s >> 6 & 63 | 128,
        r[--e] = s >> 12 | 224)
    }
    r[--e] = 0;
    for (var i = new ko, a = []; e > 2; ) {
        for (a[0] = 0; a[0] == 0; )
            i.nextBytes(a);
        r[--e] = a[0]
    }

    
    r[--e] = 2;
    r[--e] = 0;
  

  return new Ce(r)
}

var ky = function() {
    var t = function(e, r) {
        return t = Object.setPrototypeOf || {
            __proto__: []
        }instanceof Array && function(n, s) {
            n.__proto__ = s
        }
        || function(n, s) {
            for (var i in s)
                Object.prototype.hasOwnProperty.call(s, i) && (n[i] = s[i])
        }
        ,
        t(e, r)
    };
    return function(e, r) {
        if (typeof r != "function" && r !== null)
            throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
        t(e, r);
        function n() {
            this.constructor = e
        }
        e.prototype = r === null ? Object.create(r) : (n.prototype = r.prototype,
        new n)
    }
}();;





var kr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
  , Md = "=";
function ei(t) {
    var e, r, n = "";
    for (e = 0; e + 3 <= t.length; e += 3)
        r = parseInt(t.substring(e, e + 3), 16),
        n += kr.charAt(r >> 6) + kr.charAt(r & 63);
    for (e + 1 == t.length ? (r = parseInt(t.substring(e, e + 1), 16),
    n += kr.charAt(r << 2)) : e + 2 == t.length && (r = parseInt(t.substring(e, e + 2), 16),
    n += kr.charAt(r >> 2) + kr.charAt((r & 3) << 4)); (n.length & 3) > 0; )
        n += Md;
    return n
};


var Ti = [], tn, qt;
tn = "0".charCodeAt(0);
for (qt = 0; qt <= 9; ++qt)
    Ti[tn++] = qt;
tn = "a".charCodeAt(0);
for (qt = 10; qt < 36; ++qt)
    Ti[tn++] = qt;
tn = "A".charCodeAt(0);
for (qt = 10; qt < 36; ++qt)
    Ti[tn++] = qt;


function Mc(t, e) {
    var r = Ti[t.charCodeAt(e)];
    return r ?? -1
}

var Ce = function() {
    function t(e, r, n) {
        e != null && (typeof e == "number" ? this.fromNumber(e, r, n) : r == null && typeof e != "string" ? this.fromString(e, 256) : this.fromString(e, r))
    }
    return t.prototype.toString = function(e) {
        if (this.s < 0)
            return "-" + this.negate().toString(e);
        var r;
        if (e == 16)
            r = 4;
        else if (e == 8)
            r = 3;
        else if (e == 2)
            r = 1;
        else if (e == 32)
            r = 5;
        else if (e == 4)
            r = 2;
        else
            return this.toRadix(e);
        var n = (1 << r) - 1, s, i = !1, a = "", o = this.t, l = this.DB - o * this.DB % r;
        if (o-- > 0)
            for (l < this.DB && (s = this[o] >> l) > 0 && (i = !0,
            a = v0(s)); o >= 0; )
                l < r ? (s = (this[o] & (1 << l) - 1) << r - l,
                s |= this[--o] >> (l += this.DB - r)) : (s = this[o] >> (l -= r) & n,
                l <= 0 && (l += this.DB,
                --o)),
                s > 0 && (i = !0),
                i && (a += v0(s));
        return i ? a : "0"
    }
    ,
    t.prototype.negate = function() {
        var e = Me();
        return t.ZERO.subTo(this, e),
        e
    }
    ,
    t.prototype.abs = function() {
        return this.s < 0 ? this.negate() : this
    }
    ,
    t.prototype.compareTo = function(e) {
        var r = this.s - e.s;
        if (r != 0)
            return r;
        var n = this.t;
        if (r = n - e.t,
        r != 0)
            return this.s < 0 ? -r : r;
        for (; --n >= 0; )
            if ((r = this[n] - e[n]) != 0)
                return r;
        return 0
    }
    ,
    t.prototype.bitLength = function() {
        return this.t <= 0 ? 0 : this.DB * (this.t - 1) + gs(this[this.t - 1] ^ this.s & this.DM)
    }
    ,
    t.prototype.mod = function(e) {
        var r = Me();
        return this.abs().divRemTo(e, null, r),
        this.s < 0 && r.compareTo(t.ZERO) > 0 && e.subTo(r, r),
        r
    }
    ,
    t.prototype.modPowInt = function(e, r) {
        var n;
        return e < 256 || r.isEven() ? n = new Sc(r) : n = new Tc(r),
        this.exp(e, n)
    }
    ,
    t.prototype.clone = function() {
        var e = Me();
        return this.copyTo(e),
        e
    }
    ,
    t.prototype.intValue = function() {
        if (this.s < 0) {
            if (this.t == 1)
                return this[0] - this.DV;
            if (this.t == 0)
                return -1
        } else {
            if (this.t == 1)
                return this[0];
            if (this.t == 0)
                return 0
        }
        return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0]
    }
    ,
    t.prototype.byteValue = function() {
        return this.t == 0 ? this.s : this[0] << 24 >> 24
    }
    ,
    t.prototype.shortValue = function() {
        return this.t == 0 ? this.s : this[0] << 16 >> 16
    }
    ,
    t.prototype.signum = function() {
        return this.s < 0 ? -1 : this.t <= 0 || this.t == 1 && this[0] <= 0 ? 0 : 1
    }
    ,
    t.prototype.toByteArray = function() {
        var e = this.t
          , r = [];
        r[0] = this.s;
        var n = this.DB - e * this.DB % 8, s, i = 0;
        if (e-- > 0)
            for (n < this.DB && (s = this[e] >> n) != (this.s & this.DM) >> n && (r[i++] = s | this.s << this.DB - n); e >= 0; )
                n < 8 ? (s = (this[e] & (1 << n) - 1) << 8 - n,
                s |= this[--e] >> (n += this.DB - 8)) : (s = this[e] >> (n -= 8) & 255,
                n <= 0 && (n += this.DB,
                --e)),
                s & 128 && (s |= -256),
                i == 0 && (this.s & 128) != (s & 128) && ++i,
                (i > 0 || s != this.s) && (r[i++] = s);
        return r
    }
    ,
    t.prototype.equals = function(e) {
        return this.compareTo(e) == 0
    }
    ,
    t.prototype.min = function(e) {
        return this.compareTo(e) < 0 ? this : e
    }
    ,
    t.prototype.max = function(e) {
        return this.compareTo(e) > 0 ? this : e
    }
    ,
    t.prototype.and = function(e) {
        var r = Me();
        return this.bitwiseTo(e, hy, r),
        r
    }
    ,
    t.prototype.or = function(e) {
        var r = Me();
        return this.bitwiseTo(e, vs, r),
        r
    }
    ,
    t.prototype.xor = function(e) {
        var r = Me();
        return this.bitwiseTo(e, xc, r),
        r
    }
    ,
    t.prototype.andNot = function(e) {
        var r = Me();
        return this.bitwiseTo(e, wc, r),
        r
    }
    ,
    t.prototype.not = function() {
        for (var e = Me(), r = 0; r < this.t; ++r)
            e[r] = this.DM & ~this[r];
        return e.t = this.t,
        e.s = ~this.s,
        e
    }
    ,
    t.prototype.shiftLeft = function(e) {
        var r = Me();
        return e < 0 ? this.rShiftTo(-e, r) : this.lShiftTo(e, r),
        r
    }
    ,
    t.prototype.shiftRight = function(e) {
        var r = Me();
        return e < 0 ? this.lShiftTo(-e, r) : this.rShiftTo(e, r),
        r
    }
    ,
    t.prototype.getLowestSetBit = function() {
        for (var e = 0; e < this.t; ++e)
            if (this[e] != 0)
                return e * this.DB + vy(this[e]);
        return this.s < 0 ? this.t * this.DB : -1
    }
    ,
    t.prototype.bitCount = function() {
        for (var e = 0, r = this.s & this.DM, n = 0; n < this.t; ++n)
            e += gy(this[n] ^ r);
        return e
    }
    ,
    t.prototype.testBit = function(e) {
        var r = Math.floor(e / this.DB);
        return r >= this.t ? this.s != 0 : (this[r] & 1 << e % this.DB) != 0
    }
    ,
    t.prototype.setBit = function(e) {
        return this.changeBit(e, vs)
    }
    ,
    t.prototype.clearBit = function(e) {
        return this.changeBit(e, wc)
    }
    ,
    t.prototype.flipBit = function(e) {
        return this.changeBit(e, xc)
    }
    ,
    t.prototype.add = function(e) {
        var r = Me();
        return this.addTo(e, r),
        r
    }
    ,
    t.prototype.subtract = function(e) {
        var r = Me();
        return this.subTo(e, r),
        r
    }
    ,
    t.prototype.multiply = function(e) {
        var r = Me();
        return this.multiplyTo(e, r),
        r
    }
    ,
    t.prototype.divide = function(e) {
        var r = Me();
        return this.divRemTo(e, r, null),
        r
    }
    ,
    t.prototype.remainder = function(e) {
        var r = Me();
        return this.divRemTo(e, null, r),
        r
    }
    ,
    t.prototype.divideAndRemainder = function(e) {
        var r = Me()
          , n = Me();
        return this.divRemTo(e, r, n),
        [r, n]
    }
    ,
    t.prototype.modPow = function(e, r) {
        var n = e.bitLength(), s, i = O0(1), a;
        if (n <= 0)
            return i;
        n < 18 ? s = 1 : n < 48 ? s = 3 : n < 144 ? s = 4 : n < 768 ? s = 5 : s = 6,
        n < 8 ? a = new Sc(r) : r.isEven() ? a = new Cy(r) : a = new Tc(r);
        var o = []
          , l = 3
          , c = s - 1
          , u = (1 << s) - 1;
        if (o[1] = a.convert(this),
        s > 1) {
            var d = Me();
            for (a.sqrTo(o[1], d); l <= u; )
                o[l] = Me(),
                a.mulTo(d, o[l - 2], o[l]),
                l += 2
        }
        var f = e.t - 1, p, g = !0, h = Me(), y;
        for (n = gs(e[f]) - 1; f >= 0; ) {
            for (n >= c ? p = e[f] >> n - c & u : (p = (e[f] & (1 << n + 1) - 1) << c - n,
            f > 0 && (p |= e[f - 1] >> this.DB + n - c)),
            l = s; !(p & 1); )
                p >>= 1,
                --l;
            if ((n -= l) < 0 && (n += this.DB,
            --f),
            g)
                o[p].copyTo(i),
                g = !1;
            else {
                for (; l > 1; )
                    a.sqrTo(i, h),
                    a.sqrTo(h, i),
                    l -= 2;
                l > 0 ? a.sqrTo(i, h) : (y = i,
                i = h,
                h = y),
                a.mulTo(h, o[p], i)
            }
            for (; f >= 0 && !(e[f] & 1 << n); )
                a.sqrTo(i, h),
                y = i,
                i = h,
                h = y,
                --n < 0 && (n = this.DB - 1,
                --f)
        }
        return a.revert(i)
    }
    ,
    t.prototype.modInverse = function(e) {
        var r = e.isEven();
        if (this.isEven() && r || e.signum() == 0)
            return t.ZERO;
        for (var n = e.clone(), s = this.clone(), i = O0(1), a = O0(0), o = O0(0), l = O0(1); n.signum() != 0; ) {
            for (; n.isEven(); )
                n.rShiftTo(1, n),
                r ? ((!i.isEven() || !a.isEven()) && (i.addTo(this, i),
                a.subTo(e, a)),
                i.rShiftTo(1, i)) : a.isEven() || a.subTo(e, a),
                a.rShiftTo(1, a);
            for (; s.isEven(); )
                s.rShiftTo(1, s),
                r ? ((!o.isEven() || !l.isEven()) && (o.addTo(this, o),
                l.subTo(e, l)),
                o.rShiftTo(1, o)) : l.isEven() || l.subTo(e, l),
                l.rShiftTo(1, l);
            n.compareTo(s) >= 0 ? (n.subTo(s, n),
            r && i.subTo(o, i),
            a.subTo(l, a)) : (s.subTo(n, s),
            r && o.subTo(i, o),
            l.subTo(a, l))
        }
        if (s.compareTo(t.ONE) != 0)
            return t.ZERO;
        if (l.compareTo(e) >= 0)
            return l.subtract(e);
        if (l.signum() < 0)
            l.addTo(e, l);
        else
            return l;
        return l.signum() < 0 ? l.add(e) : l
    }
    ,
    t.prototype.pow = function(e) {
        return this.exp(e, new Ey)
    }
    ,
    t.prototype.gcd = function(e) {
        var r = this.s < 0 ? this.negate() : this.clone()
          , n = e.s < 0 ? e.negate() : e.clone();
        if (r.compareTo(n) < 0) {
            var s = r;
            r = n,
            n = s
        }
        var i = r.getLowestSetBit()
          , a = n.getLowestSetBit();
        if (a < 0)
            return r;
        for (i < a && (a = i),
        a > 0 && (r.rShiftTo(a, r),
        n.rShiftTo(a, n)); r.signum() > 0; )
            (i = r.getLowestSetBit()) > 0 && r.rShiftTo(i, r),
            (i = n.getLowestSetBit()) > 0 && n.rShiftTo(i, n),
            r.compareTo(n) >= 0 ? (r.subTo(n, r),
            r.rShiftTo(1, r)) : (n.subTo(r, n),
            n.rShiftTo(1, n));
        return a > 0 && n.lShiftTo(a, n),
        n
    }
    ,
    t.prototype.isProbablePrime = function(e) {
        var r, n = this.abs();
        if (n.t == 1 && n[0] <= mt[mt.length - 1]) {
            for (r = 0; r < mt.length; ++r)
                if (n[0] == mt[r])
                    return !0;
            return !1
        }
        if (n.isEven())
            return !1;
        for (r = 1; r < mt.length; ) {
            for (var s = mt[r], i = r + 1; i < mt.length && s < Ay; )
                s *= mt[i++];
            for (s = n.modInt(s); r < i; )
                if (s % mt[r++] == 0)
                    return !1
        }
        return n.millerRabin(e)
    }
    ,
    t.prototype.copyTo = function(e) {
        for (var r = this.t - 1; r >= 0; --r)
            e[r] = this[r];
        e.t = this.t,
        e.s = this.s
    }
    ,
    t.prototype.fromInt = function(e) {
        this.t = 1,
        this.s = e < 0 ? -1 : 0,
        e > 0 ? this[0] = e : e < -1 ? this[0] = e + this.DV : this.t = 0
    }
    ,
    t.prototype.fromString = function(e, r) {
        var n;
        if (r == 16)
            n = 4;
        else if (r == 8)
            n = 3;
        else if (r == 256)
            n = 8;
        else if (r == 2)
            n = 1;
        else if (r == 32)
            n = 5;
        else if (r == 4)
            n = 2;
        else {
            this.fromRadix(e, r);
            return
        }
        this.t = 0,
        this.s = 0;
        for (var s = e.length, i = !1, a = 0; --s >= 0; ) {
            var o = n == 8 ? +e[s] & 255 : Mc(e, s);
            if (o < 0) {
                e.charAt(s) == "-" && (i = !0);
                continue
            }
            i = !1,
            a == 0 ? this[this.t++] = o : a + n > this.DB ? (this[this.t - 1] |= (o & (1 << this.DB - a) - 1) << a,
            this[this.t++] = o >> this.DB - a) : this[this.t - 1] |= o << a,
            a += n,
            a >= this.DB && (a -= this.DB)
        }
        n == 8 && +e[0] & 128 && (this.s = -1,
        a > 0 && (this[this.t - 1] |= (1 << this.DB - a) - 1 << a)),
        this.clamp(),
        i && t.ZERO.subTo(this, this)
    }
    ,
    t.prototype.clamp = function() {
        for (var e = this.s & this.DM; this.t > 0 && this[this.t - 1] == e; )
            --this.t
    }
    ,
    t.prototype.dlShiftTo = function(e, r) {
        var n;
        for (n = this.t - 1; n >= 0; --n)
            r[n + e] = this[n];
        for (n = e - 1; n >= 0; --n)
            r[n] = 0;
        r.t = this.t + e,
        r.s = this.s
    }
    ,
    t.prototype.drShiftTo = function(e, r) {
        for (var n = e; n < this.t; ++n)
            r[n - e] = this[n];
        r.t = Math.max(this.t - e, 0),
        r.s = this.s
    }
    ,
    t.prototype.lShiftTo = function(e, r) {
        for (var n = e % this.DB, s = this.DB - n, i = (1 << s) - 1, a = Math.floor(e / this.DB), o = this.s << n & this.DM, l = this.t - 1; l >= 0; --l)
            r[l + a + 1] = this[l] >> s | o,
            o = (this[l] & i) << n;
        for (var l = a - 1; l >= 0; --l)
            r[l] = 0;
        r[a] = o,
        r.t = this.t + a + 1,
        r.s = this.s,
        r.clamp()
    }
    ,
    t.prototype.rShiftTo = function(e, r) {
        r.s = this.s;
        var n = Math.floor(e / this.DB);
        if (n >= this.t) {
            r.t = 0;
            return
        }
        var s = e % this.DB
          , i = this.DB - s
          , a = (1 << s) - 1;
        r[0] = this[n] >> s;
        for (var o = n + 1; o < this.t; ++o)
            r[o - n - 1] |= (this[o] & a) << i,
            r[o - n] = this[o] >> s;
        s > 0 && (r[this.t - n - 1] |= (this.s & a) << i),
        r.t = this.t - n,
        r.clamp()
    }
    ,
    t.prototype.subTo = function(e, r) {
        for (var n = 0, s = 0, i = Math.min(e.t, this.t); n < i; )
            s += this[n] - e[n],
            r[n++] = s & this.DM,
            s >>= this.DB;
        if (e.t < this.t) {
            for (s -= e.s; n < this.t; )
                s += this[n],
                r[n++] = s & this.DM,
                s >>= this.DB;
            s += this.s
        } else {
            for (s += this.s; n < e.t; )
                s -= e[n],
                r[n++] = s & this.DM,
                s >>= this.DB;
            s -= e.s
        }
        r.s = s < 0 ? -1 : 0,
        s < -1 ? r[n++] = this.DV + s : s > 0 && (r[n++] = s),
        r.t = n,
        r.clamp()
    }
    ,
    t.prototype.multiplyTo = function(e, r) {
        var n = this.abs()
          , s = e.abs()
          , i = n.t;
        for (r.t = i + s.t; --i >= 0; )
            r[i] = 0;
        for (i = 0; i < s.t; ++i)
            r[i + n.t] = n.am(0, s[i], r, i, 0, n.t);
        r.s = 0,
        r.clamp(),
        this.s != e.s && t.ZERO.subTo(r, r)
    }
    ,
    t.prototype.squareTo = function(e) {
        for (var r = this.abs(), n = e.t = 2 * r.t; --n >= 0; )
            e[n] = 0;
        for (n = 0; n < r.t - 1; ++n) {
            var s = r.am(n, r[n], e, 2 * n, 0, 1);
            (e[n + r.t] += r.am(n + 1, 2 * r[n], e, 2 * n + 1, s, r.t - n - 1)) >= r.DV && (e[n + r.t] -= r.DV,
            e[n + r.t + 1] = 1)
        }
        e.t > 0 && (e[e.t - 1] += r.am(n, r[n], e, 2 * n, 0, 1)),
        e.s = 0,
        e.clamp()
    }
    ,
    t.prototype.divRemTo = function(e, r, n) {
        var s = e.abs();
        if (!(s.t <= 0)) {
            var i = this.abs();
            if (i.t < s.t) {
                r != null && r.fromInt(0),
                n != null && this.copyTo(n);
                return
            }
            n == null && (n = Me());
            var a = Me()
              , o = this.s
              , l = e.s
              , c = this.DB - gs(s[s.t - 1]);
            c > 0 ? (s.lShiftTo(c, a),
            i.lShiftTo(c, n)) : (s.copyTo(a),
            i.copyTo(n));
            var u = a.t
              , d = a[u - 1];
            if (d != 0) {
                var f = d * (1 << this.F1) + (u > 1 ? a[u - 2] >> this.F2 : 0)
                  , p = this.FV / f
                  , g = (1 << this.F1) / f
                  , h = 1 << this.F2
                  , y = n.t
                  , b = y - u
                  , v = r ?? Me();
                for (a.dlShiftTo(b, v),
                n.compareTo(v) >= 0 && (n[n.t++] = 1,
                n.subTo(v, n)),
                t.ONE.dlShiftTo(u, v),
                v.subTo(a, a); a.t < u; )
                    a[a.t++] = 0;
                for (; --b >= 0; ) {
                    var m = n[--y] == d ? this.DM : Math.floor(n[y] * p + (n[y - 1] + h) * g);
                    if ((n[y] += a.am(0, m, n, b, 0, u)) < m)
                        for (a.dlShiftTo(b, v),
                        n.subTo(v, n); n[y] < --m; )
                            n.subTo(v, n)
                }
                r != null && (n.drShiftTo(u, r),
                o != l && t.ZERO.subTo(r, r)),
                n.t = u,
                n.clamp(),
                c > 0 && n.rShiftTo(c, n),
                o < 0 && t.ZERO.subTo(n, n)
            }
        }
    }
    ,
    t.prototype.invDigit = function() {
        if (this.t < 1)
            return 0;
        var e = this[0];
        if (!(e & 1))
            return 0;
        var r = e & 3;
        return r = r * (2 - (e & 15) * r) & 15,
        r = r * (2 - (e & 255) * r) & 255,
        r = r * (2 - ((e & 65535) * r & 65535)) & 65535,
        r = r * (2 - e * r % this.DV) % this.DV,
        r > 0 ? this.DV - r : -r
    }
    ,
    t.prototype.isEven = function() {
        return (this.t > 0 ? this[0] & 1 : this.s) == 0
    }
    ,
    t.prototype.exp = function(e, r) {
        if (e > 4294967295 || e < 1)
            return t.ONE;
        var n = Me()
          , s = Me()
          , i = r.convert(this)
          , a = gs(e) - 1;
        for (i.copyTo(n); --a >= 0; )
            if (r.sqrTo(n, s),
            (e & 1 << a) > 0)
                r.mulTo(s, i, n);
            else {
                var o = n;
                n = s,
                s = o
            }
        return r.revert(n)
    }
    ,
    t.prototype.chunkSize = function(e) {
        return Math.floor(Math.LN2 * this.DB / Math.log(e))
    }
    ,
    t.prototype.toRadix = function(e) {
        if (e == null && (e = 10),
        this.signum() == 0 || e < 2 || e > 36)
            return "0";
        var r = this.chunkSize(e)
          , n = Math.pow(e, r)
          , s = O0(n)
          , i = Me()
          , a = Me()
          , o = "";
        for (this.divRemTo(s, i, a); i.signum() > 0; )
            o = (n + a.intValue()).toString(e).substr(1) + o,
            i.divRemTo(s, i, a);
        return a.intValue().toString(e) + o
    }
    ,
    t.prototype.fromRadix = function(e, r) {
        this.fromInt(0),
        r == null && (r = 10);
        for (var n = this.chunkSize(r), s = Math.pow(r, n), i = !1, a = 0, o = 0, l = 0; l < e.length; ++l) {
            var c = Mc(e, l);
            if (c < 0) {
                e.charAt(l) == "-" && this.signum() == 0 && (i = !0);
                continue
            }
            o = r * o + c,
            ++a >= n && (this.dMultiply(s),
            this.dAddOffset(o, 0),
            a = 0,
            o = 0)
        }
        a > 0 && (this.dMultiply(Math.pow(r, a)),
        this.dAddOffset(o, 0)),
        i && t.ZERO.subTo(this, this)
    }
    ,
    t.prototype.fromNumber = function(e, r, n) {
        if (typeof r == "number")
            if (e < 2)
                this.fromInt(1);
            else
                for (this.fromNumber(e, n),
                this.testBit(e - 1) || this.bitwiseTo(t.ONE.shiftLeft(e - 1), vs, this),
                this.isEven() && this.dAddOffset(1, 0); !this.isProbablePrime(r); )
                    this.dAddOffset(2, 0),
                    this.bitLength() > e && this.subTo(t.ONE.shiftLeft(e - 1), this);
        else {
            var s = []
              , i = e & 7;
            s.length = (e >> 3) + 1,
            r.nextBytes(s),
            i > 0 ? s[0] &= (1 << i) - 1 : s[0] = 0,
            this.fromString(s, 256)
        }
    }
    ,
    t.prototype.bitwiseTo = function(e, r, n) {
        var s, i, a = Math.min(e.t, this.t);
        for (s = 0; s < a; ++s)
            n[s] = r(this[s], e[s]);
        if (e.t < this.t) {
            for (i = e.s & this.DM,
            s = a; s < this.t; ++s)
                n[s] = r(this[s], i);
            n.t = this.t
        } else {
            for (i = this.s & this.DM,
            s = a; s < e.t; ++s)
                n[s] = r(i, e[s]);
            n.t = e.t
        }
        n.s = r(this.s, e.s),
        n.clamp()
    }
    ,
    t.prototype.changeBit = function(e, r) {
        var n = t.ONE.shiftLeft(e);
        return this.bitwiseTo(n, r, n),
        n
    }
    ,
    t.prototype.addTo = function(e, r) {
        for (var n = 0, s = 0, i = Math.min(e.t, this.t); n < i; )
            s += this[n] + e[n],
            r[n++] = s & this.DM,
            s >>= this.DB;
        if (e.t < this.t) {
            for (s += e.s; n < this.t; )
                s += this[n],
                r[n++] = s & this.DM,
                s >>= this.DB;
            s += this.s
        } else {
            for (s += this.s; n < e.t; )
                s += e[n],
                r[n++] = s & this.DM,
                s >>= this.DB;
            s += e.s
        }
        r.s = s < 0 ? -1 : 0,
        s > 0 ? r[n++] = s : s < -1 && (r[n++] = this.DV + s),
        r.t = n,
        r.clamp()
    }
    ,
    t.prototype.dMultiply = function(e) {
        this[this.t] = this.am(0, e - 1, this, 0, 0, this.t),
        ++this.t,
        this.clamp()
    }
    ,
    t.prototype.dAddOffset = function(e, r) {
        if (e != 0) {
            for (; this.t <= r; )
                this[this.t++] = 0;
            for (this[r] += e; this[r] >= this.DV; )
                this[r] -= this.DV,
                ++r >= this.t && (this[this.t++] = 0),
                ++this[r]
        }
    }
    ,
    t.prototype.multiplyLowerTo = function(e, r, n) {
        var s = Math.min(this.t + e.t, r);
        for (n.s = 0,
        n.t = s; s > 0; )
            n[--s] = 0;
        for (var i = n.t - this.t; s < i; ++s)
            n[s + this.t] = this.am(0, e[s], n, s, 0, this.t);
        for (var i = Math.min(e.t, r); s < i; ++s)
            this.am(0, e[s], n, s, 0, r - s);
        n.clamp()
    }
    ,
    t.prototype.multiplyUpperTo = function(e, r, n) {
        --r;
        var s = n.t = this.t + e.t - r;
        for (n.s = 0; --s >= 0; )
            n[s] = 0;
        for (s = Math.max(r - this.t, 0); s < e.t; ++s)
            n[this.t + s - r] = this.am(r - s, e[s], n, 0, 0, this.t + s - r);
        n.clamp(),
        n.drShiftTo(1, n)
    }
    ,
    t.prototype.modInt = function(e) {
        if (e <= 0)
            return 0;
        var r = this.DV % e
          , n = this.s < 0 ? e - 1 : 0;
        if (this.t > 0)
            if (r == 0)
                n = this[0] % e;
            else
                for (var s = this.t - 1; s >= 0; --s)
                    n = (r * n + this[s]) % e;
        return n
    }
    ,
    t.prototype.millerRabin = function(e) {
        var r = this.subtract(t.ONE)
          , n = r.getLowestSetBit();
        if (n <= 0)
            return !1;
        var s = r.shiftRight(n);
        e = e + 1 >> 1,
        e > mt.length && (e = mt.length);
        for (var i = Me(), a = 0; a < e; ++a) {
            i.fromInt(mt[Math.floor(Math.random() * mt.length)]);
            var o = i.modPow(s, this);
            if (o.compareTo(t.ONE) != 0 && o.compareTo(r) != 0) {
                for (var l = 1; l++ < n && o.compareTo(r) != 0; )
                    if (o = o.modPowInt(2, this),
                    o.compareTo(t.ONE) == 0)
                        return !1;
                if (o.compareTo(r) != 0)
                    return !1
            }
        }
        return !0
    }
    ,
    t.prototype.square = function() {
        var e = Me();
        return this.squareTo(e),
        e
    }
    ,
    t.prototype.gcda = function(e, r) {
        var n = this.s < 0 ? this.negate() : this.clone()
          , s = e.s < 0 ? e.negate() : e.clone();
        if (n.compareTo(s) < 0) {
            var i = n;
            n = s,
            s = i
        }
        var a = n.getLowestSetBit()
          , o = s.getLowestSetBit();
        if (o < 0) {
            r(n);
            return
        }
        a < o && (o = a),
        o > 0 && (n.rShiftTo(o, n),
        s.rShiftTo(o, s));
        var l = function() {
            (a = n.getLowestSetBit()) > 0 && n.rShiftTo(a, n),
            (a = s.getLowestSetBit()) > 0 && s.rShiftTo(a, s),
            n.compareTo(s) >= 0 ? (n.subTo(s, n),
            n.rShiftTo(1, n)) : (s.subTo(n, s),
            s.rShiftTo(1, s)),
            n.signum() > 0 ? setTimeout(l, 0) : (o > 0 && s.lShiftTo(o, s),
            setTimeout(function() {
                r(s)
            }, 0))
        };
        setTimeout(l, 10)
    }
    ,
    t.prototype.fromNumberAsync = function(e, r, n, s) {
        if (typeof r == "number")
            if (e < 2)
                this.fromInt(1);
            else {
                this.fromNumber(e, n),
                this.testBit(e - 1) || this.bitwiseTo(t.ONE.shiftLeft(e - 1), vs, this),
                this.isEven() && this.dAddOffset(1, 0);
                var i = this
                  , a = function() {
                    i.dAddOffset(2, 0),
                    i.bitLength() > e && i.subTo(t.ONE.shiftLeft(e - 1), i),
                    i.isProbablePrime(r) ? setTimeout(function() {
                        s()
                    }, 0) : setTimeout(a, 0)
                };
                setTimeout(a, 0)
            }
        else {
            var o = []
              , l = e & 7;
            o.length = (e >> 3) + 1,
            r.nextBytes(o),
            l > 0 ? o[0] &= (1 << l) - 1 : o[0] = 0,
            this.fromString(o, 256)
        }
    }
    ,
    t
}();


Ce.prototype.am = function(e, r, n, s, i, a) {
    for (var o = r & 16383, l = r >> 14; --a >= 0; ) {
        var c = this[e] & 16383
          , u = this[e++] >> 14
          , d = l * c + u * o;
        c = o * c + ((d & 16383) << 14) + n[s] + i,
        i = (c >> 28) + (d >> 14) + l * u,
        n[s++] = c & 268435455
    }
    return i
}

var q0 = 28;
Ce.prototype.DB = q0;
Ce.prototype.DM = (1 << q0) - 1;
Ce.prototype.DV = 1 << q0;
var Il = 52;
Ce.prototype.FV = Math.pow(2, Il);
Ce.prototype.F1 = Il - q0;
Ce.prototype.F2 = 2 * q0 - Il;




function Me() {
    return new Ce(null)
};

function O0(t) {
    var e = Me();
    return e.fromInt(t),
    e
};

Ce.ZERO = O0(0);
Ce.ONE = O0(1);



function gs(t) {
    var e = 1, r;
    return (r = t >>> 16) != 0 && (t = r,
    e += 16),
    (r = t >> 8) != 0 && (t = r,
    e += 8),
    (r = t >> 4) != 0 && (t = r,
    e += 4),
    (r = t >> 2) != 0 && (t = r,
    e += 2),
    (r = t >> 1) != 0 && (t = r,
    e += 1),
    e
};


function Ke(t, e) {
    return new Ce(t,e)
};

var Ec = function() {
    function t(e) {
        var r = e.get();
        if (this.tagClass = r >> 6,
        this.tagConstructed = (r & 32) !== 0,
        this.tagNumber = r & 31,
        this.tagNumber == 31) {
            var n = new xn;
            do
                r = e.get(),
                n.mulAdd(128, r & 127);
            while (r & 128);
            this.tagNumber = n.simplify()
        }
    }
    return t.prototype.isUniversal = function() {
        return this.tagClass === 0
    }
    ,
    t.prototype.isEOC = function() {
        return this.tagClass === 0 && this.tagNumber === 0
    }
    ,
    t
}();


var ta = function() {
    function t(e, r) {
        this.hexDigits = "0123456789ABCDEF",
        e instanceof t ? (this.enc = e.enc,
        this.pos = e.pos) : (this.enc = e,
        this.pos = r)
    }
    return t.prototype.get = function(e) {
        if (e === void 0 && (e = this.pos++),
        e >= this.enc.length)
            throw new Error("Requesting byte offset " + e + " on a stream of length " + this.enc.length);
        return typeof this.enc == "string" ? this.enc.charCodeAt(e) : this.enc[e]
    }
    ,
    t.prototype.hexByte = function(e) {
        return this.hexDigits.charAt(e >> 4 & 15) + this.hexDigits.charAt(e & 15)
    }
    ,
    t.prototype.hexDump = function(e, r, n) {
        for (var s = "", i = e; i < r; ++i)
            if (s += this.hexByte(this.get(i)),
            n !== !0)
                switch (i & 15) {
                case 7:
                    s += "  ";
                    break;
                case 15:
                    s += `
`;
                    break;
                default:
                    s += " "
                }
        return s
    }
    ,
    t.prototype.isASCII = function(e, r) {
        for (var n = e; n < r; ++n) {
            var s = this.get(n);
            if (s < 32 || s > 176)
                return !1
        }
        return !0
    }
    ,
    t.prototype.parseStringISO = function(e, r) {
        for (var n = "", s = e; s < r; ++s)
            n += String.fromCharCode(this.get(s));
        return n
    }
    ,
    t.prototype.parseStringUTF = function(e, r) {
        for (var n = "", s = e; s < r; ) {
            var i = this.get(s++);
            i < 128 ? n += String.fromCharCode(i) : i > 191 && i < 224 ? n += String.fromCharCode((i & 31) << 6 | this.get(s++) & 63) : n += String.fromCharCode((i & 15) << 12 | (this.get(s++) & 63) << 6 | this.get(s++) & 63)
        }
        return n
    }
    ,
    t.prototype.parseStringBMP = function(e, r) {
        for (var n = "", s, i, a = e; a < r; )
            s = this.get(a++),
            i = this.get(a++),
            n += String.fromCharCode(s << 8 | i);
        return n
    }
    ,
    t.prototype.parseTime = function(e, r, n) {
        var s = this.parseStringISO(e, r)
          , i = (n ? yy : by).exec(s);
        return i ? (n && (i[1] = +i[1],
        i[1] += +i[1] < 70 ? 2e3 : 1900),
        s = i[1] + "-" + i[2] + "-" + i[3] + " " + i[4],
        i[5] && (s += ":" + i[5],
        i[6] && (s += ":" + i[6],
        i[7] && (s += "." + i[7]))),
        i[8] && (s += " UTC",
        i[8] != "Z" && (s += i[8],
        i[9] && (s += ":" + i[9]))),
        s) : "Unrecognized time: " + s
    }
    ,
    t.prototype.parseInteger = function(e, r) {
        for (var n = this.get(e), s = n > 127, i = s ? 255 : 0, a, o = ""; n == i && ++e < r; )
            n = this.get(e);
        if (a = r - e,
        a === 0)
            return s ? -1 : 0;
        if (a > 4) {
            for (o = n,
            a <<= 3; !((+o ^ i) & 128); )
                o = +o << 1,
                --a;
            o = "(" + a + ` bit)
`
        }
        s && (n = n - 256);
        for (var l = new xn(n), c = e + 1; c < r; ++c)
            l.mulAdd(256, this.get(c));
        return o + l.toString()
    }
    ,
    t.prototype.parseBitString = function(e, r, n) {
        for (var s = this.get(e), i = (r - e - 1 << 3) - s, a = "(" + i + ` bit)
`, o = "", l = e + 1; l < r; ++l) {
            for (var c = this.get(l), u = l == r - 1 ? s : 0, d = 7; d >= u; --d)
                o += c >> d & 1 ? "1" : "0";
            if (o.length > n)
                return a + jr(o, n)
        }
        return a + o
    }
    ,
    t.prototype.parseOctetString = function(e, r, n) {
        if (this.isASCII(e, r))
            return jr(this.parseStringISO(e, r), n);
        var s = r - e
          , i = "(" + s + ` byte)
`;
        n /= 2,
        s > n && (r = e + n);
        for (var a = e; a < r; ++a)
            i += this.hexByte(this.get(a));
        return s > n && (i += zd),
        i
    }
    ,
    t.prototype.parseOID = function(e, r, n) {
        for (var s = "", i = new xn, a = 0, o = e; o < r; ++o) {
            var l = this.get(o);
            if (i.mulAdd(128, l & 127),
            a += 7,
            !(l & 128)) {
                if (s === "")
                    if (i = i.simplify(),
                    i instanceof xn)
                        i.sub(80),
                        s = "2." + i.toString();
                    else {
                        var c = i < 80 ? i < 40 ? 0 : 1 : 2;
                        s = c + "." + (i - c * 40)
                    }
                else
                    s += "." + i.toString();
                if (s.length > n)
                    return jr(s, n);
                i = new xn,
                a = 0
            }
        }
        return a > 0 && (s += ".incomplete"),
        s
    }
    ,
    t
}();


var xy = function() {
    function t(e, r, n, s, i) {
        if (!(s instanceof Ec))
            throw new Error("Invalid tag value.");
        this.stream = e,
        this.header = r,
        this.length = n,
        this.tag = s,
        this.sub = i
    }
    return t.prototype.typeName = function() {
        switch (this.tag.tagClass) {
        case 0:
            switch (this.tag.tagNumber) {
            case 0:
                return "EOC";
            case 1:
                return "BOOLEAN";
            case 2:
                return "INTEGER";
            case 3:
                return "BIT_STRING";
            case 4:
                return "OCTET_STRING";
            case 5:
                return "NULL";
            case 6:
                return "OBJECT_IDENTIFIER";
            case 7:
                return "ObjectDescriptor";
            case 8:
                return "EXTERNAL";
            case 9:
                return "REAL";
            case 10:
                return "ENUMERATED";
            case 11:
                return "EMBEDDED_PDV";
            case 12:
                return "UTF8String";
            case 16:
                return "SEQUENCE";
            case 17:
                return "SET";
            case 18:
                return "NumericString";
            case 19:
                return "PrintableString";
            case 20:
                return "TeletexString";
            case 21:
                return "VideotexString";
            case 22:
                return "IA5String";
            case 23:
                return "UTCTime";
            case 24:
                return "GeneralizedTime";
            case 25:
                return "GraphicString";
            case 26:
                return "VisibleString";
            case 27:
                return "GeneralString";
            case 28:
                return "UniversalString";
            case 30:
                return "BMPString"
            }
            return "Universal_" + this.tag.tagNumber.toString();
        case 1:
            return "Application_" + this.tag.tagNumber.toString();
        case 2:
            return "[" + this.tag.tagNumber.toString() + "]";
        case 3:
            return "Private_" + this.tag.tagNumber.toString()
        }
    }
    ,
    t.prototype.content = function(e) {
        if (this.tag === void 0)
            return null;
        e === void 0 && (e = 1 / 0);
        var r = this.posContent()
          , n = Math.abs(this.length);
        if (!this.tag.isUniversal())
            return this.sub !== null ? "(" + this.sub.length + " elem)" : this.stream.parseOctetString(r, r + n, e);
        switch (this.tag.tagNumber) {
        case 1:
            return this.stream.get(r) === 0 ? "false" : "true";
        case 2:
            return this.stream.parseInteger(r, r + n);
        case 3:
            return this.sub ? "(" + this.sub.length + " elem)" : this.stream.parseBitString(r, r + n, e);
        case 4:
            return this.sub ? "(" + this.sub.length + " elem)" : this.stream.parseOctetString(r, r + n, e);
        case 6:
            return this.stream.parseOID(r, r + n, e);
        case 16:
        case 17:
            return this.sub !== null ? "(" + this.sub.length + " elem)" : "(no elem)";
        case 12:
            return jr(this.stream.parseStringUTF(r, r + n), e);
        case 18:
        case 19:
        case 20:
        case 21:
        case 22:
        case 26:
            return jr(this.stream.parseStringISO(r, r + n), e);
        case 30:
            return jr(this.stream.parseStringBMP(r, r + n), e);
        case 23:
        case 24:
            return this.stream.parseTime(r, r + n, this.tag.tagNumber == 23)
        }
        return null
    }
    ,
    t.prototype.toString = function() {
        return this.typeName() + "@" + this.stream.pos + "[header:" + this.header + ",length:" + this.length + ",sub:" + (this.sub === null ? "null" : this.sub.length) + "]"
    }
    ,
    t.prototype.toPrettyString = function(e) {
        e === void 0 && (e = "");
        var r = e + this.typeName() + " @" + this.stream.pos;
        if (this.length >= 0 && (r += "+"),
        r += this.length,
        this.tag.tagConstructed ? r += " (constructed)" : this.tag.isUniversal() && (this.tag.tagNumber == 3 || this.tag.tagNumber == 4) && this.sub !== null && (r += " (encapsulates)"),
        r += `
`,
        this.sub !== null) {
            e += "  ";
            for (var n = 0, s = this.sub.length; n < s; ++n)
                r += this.sub[n].toPrettyString(e)
        }
        return r
    }
    ,
    t.prototype.posStart = function() {
        return this.stream.pos
    }
    ,
    t.prototype.posContent = function() {
        return this.stream.pos + this.header
    }
    ,
    t.prototype.posEnd = function() {
        return this.stream.pos + this.header + Math.abs(this.length)
    }
    ,
    t.prototype.toHexString = function() {
        return this.stream.hexDump(this.posStart(), this.posEnd(), !0)
    }
    ,
    t.decodeLength = function(e) {
        var r = e.get()
          , n = r & 127;
        if (n == r)
            return n;
        if (n > 6)
            throw new Error("Length over 48 bits not supported at position " + (e.pos - 1));
        if (n === 0)
            return null;
        r = 0;
        for (var s = 0; s < n; ++s)
            r = r * 256 + e.get();
        return r
    }
    ,
    t.prototype.getHexStringValue = function() {
        var e = this.toHexString()
          , r = this.header * 2
          , n = this.length * 2;
        return e.substr(r, n)
    }
    ,
    t.decode = function(e) {
        var r;
        e instanceof ta ? r = e : r = new ta(e,0);
        var n = new ta(r)
          , s = new Ec(r)
          , i = t.decodeLength(r)
          , a = r.pos
          , o = a - n.pos
          , l = null
          , c = function() {
            var d = [];
            if (i !== null) {
                for (var f = a + i; r.pos < f; )
                    d[d.length] = t.decode(r);
                if (r.pos != f)
                    throw new Error("Content size is not correct for container starting at offset " + a)
            } else
                try {
                    for (; ; ) {
                        var p = t.decode(r);
                        if (p.tag.isEOC())
                            break;
                        d[d.length] = p
                    }
                    i = a - r.pos
                } catch (g) {
                    throw new Error("Exception while decoding undefined length content: " + g)
                }
            return d
        };
        if (s.tagConstructed)
            l = c();
        else if (s.isUniversal() && (s.tagNumber == 3 || s.tagNumber == 4))
            try {
                if (s.tagNumber == 3 && r.get() != 0)
                    throw new Error("BIT STRINGs with unused bits cannot encapsulate.");
                l = c();
                for (var u = 0; u < l.length; ++u)
                    if (l[u].tag.isEOC())
                        throw new Error("EOC is not supposed to be actual content.")
            } catch {
                l = null
            }
        if (l === null) {
            if (i === null)
                throw new Error("We can't skip over an invalid tag with undefined length at offset " + a);
            r.pos = a + Math.abs(i)
        }
        return new t(n,o,i,s,l)
    }
    ,
    t
}();






var Oo = {
    decode: function(t) {
        var e;
        if ($0 === void 0) {
            var r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
              , n = `= \f
\r     \u2028\u2029`;
            for ($0 = Object.create(null),
            e = 0; e < 64; ++e)
                $0[r.charAt(e)] = e;
            for ($0["-"] = 62,
            $0._ = 63,
            e = 0; e < n.length; ++e)
                $0[n.charAt(e)] = -1
        }
        var s = []
          , i = 0
          , a = 0;
        for (e = 0; e < t.length; ++e) {
            var o = t.charAt(e);
            if (o == "=")
                break;
            if (o = $0[o],
            o != -1) {
                if (o === void 0)
                    throw new Error("Illegal character at offset " + e);
                i |= o,
                ++a >= 4 ? (s[s.length] = i >> 16,
                s[s.length] = i >> 8 & 255,
                s[s.length] = i & 255,
                i = 0,
                a = 0) : i <<= 6
            }
        }
        switch (a) {
        case 1:
            throw new Error("Base64 encoding incomplete: at least 2 bits missing");
        case 2:
            s[s.length] = i >> 10;
            break;
        case 3:
            s[s.length] = i >> 16,
            s[s.length] = i >> 8 & 255;
            break
        }
        return s
    },
    re: /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,
    unarmor: function(t) {
        var e = Oo.re.exec(t);
        if (e)
            if (e[1])
                t = e[1];
            else if (e[2])
                t = e[2];
            else
                throw new Error("RegExp out of sync");
        return Oo.decode(t)
    }
};



var Py = function() {
    function t() {
        this.n = null,
        this.e = 0,
        this.d = null,
        this.p = null,
        this.q = null,
        this.dmp1 = null,
        this.dmq1 = null,
        this.coeff = null
    }
    return t.prototype.doPublic = function(e) {
        return e.modPowInt(this.e, this.n)
    }
    ,
    t.prototype.doPrivate = function(e) {
        if (this.p == null || this.q == null)
            return e.modPow(this.d, this.n);
        for (var r = e.mod(this.p).modPow(this.dmp1, this.p), n = e.mod(this.q).modPow(this.dmq1, this.q); r.compareTo(n) < 0; )
            r = r.add(this.p);
        return r.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)
    }
    ,
    t.prototype.setPublic = function(e, r) {
        e != null && r != null && e.length > 0 && r.length > 0 ? (this.n = Ke(e, 16),
        this.e = parseInt(r, 16)) : console.error("Invalid RSA public key")
    }
    ,
    t.prototype.encrypt = function(e) {
        var r = this.n.bitLength() + 7 >> 3;
         var n = zy(e, r);

       
 
        if (n == null)
            return null;
        var s = this.doPublic(n);
        if (s == null)
            return null;
        for (var i = s.toString(16), a = i.length, o = 0; o < r * 2 - a; o++)
            i = "0" + i;
        return i
    }
    ,
    t.prototype.setPrivate = function(e, r, n) {
        e != null && r != null && e.length > 0 && r.length > 0 ? (this.n = Ke(e, 16),
        this.e = parseInt(r, 16),
        this.d = Ke(n, 16)) : console.error("Invalid RSA private key")
    }
    ,
    t.prototype.setPrivateEx = function(e, r, n, s, i, a, o, l) {
        e != null && r != null && e.length > 0 && r.length > 0 ? (this.n = Ke(e, 16),
        this.e = parseInt(r, 16),
        this.d = Ke(n, 16),
        this.p = Ke(s, 16),
        this.q = Ke(i, 16),
        this.dmp1 = Ke(a, 16),
        this.dmq1 = Ke(o, 16),
        this.coeff = Ke(l, 16)) : console.error("Invalid RSA private key")
    }
    ,
    t.prototype.generate = function(e, r) {
        var n = new ko
          , s = e >> 1;
        this.e = parseInt(r, 16);
        for (var i = new Ce(r,16); ; ) {
            for (; this.p = new Ce(e - s,1,n),
            !(this.p.subtract(Ce.ONE).gcd(i).compareTo(Ce.ONE) == 0 && this.p.isProbablePrime(10)); )
                ;
            for (; this.q = new Ce(s,1,n),
            !(this.q.subtract(Ce.ONE).gcd(i).compareTo(Ce.ONE) == 0 && this.q.isProbablePrime(10)); )
                ;
            if (this.p.compareTo(this.q) <= 0) {
                var a = this.p;
                this.p = this.q,
                this.q = a
            }
            var o = this.p.subtract(Ce.ONE)
              , l = this.q.subtract(Ce.ONE)
              , c = o.multiply(l);
            if (c.gcd(i).compareTo(Ce.ONE) == 0) {
                this.n = this.p.multiply(this.q),
                this.d = i.modInverse(c),
                this.dmp1 = this.d.mod(o),
                this.dmq1 = this.d.mod(l),
                this.coeff = this.q.modInverse(this.p);
                break
            }
        }
    }
    ,
    t.prototype.decrypt = function(e) {
        var r = Ke(e, 16)
          , n = this.doPrivate(r);
        return n == null ? null : Iy(n, this.n.bitLength() + 7 >> 3)
    }
    ,
    t.prototype.generateAsync = function(e, r, n) {
        var s = new ko
          , i = e >> 1;
        this.e = parseInt(r, 16);
        var a = new Ce(r,16)
          , o = this
          , l = function() {
            var c = function() {
                if (o.p.compareTo(o.q) <= 0) {
                    var f = o.p;
                    o.p = o.q,
                    o.q = f
                }
                var p = o.p.subtract(Ce.ONE)
                  , g = o.q.subtract(Ce.ONE)
                  , h = p.multiply(g);
                h.gcd(a).compareTo(Ce.ONE) == 0 ? (o.n = o.p.multiply(o.q),
                o.d = a.modInverse(h),
                o.dmp1 = o.d.mod(p),
                o.dmq1 = o.d.mod(g),
                o.coeff = o.q.modInverse(o.p),
                setTimeout(function() {
                    n()
                }, 0)) : setTimeout(l, 0)
            }
              , u = function() {
                o.q = Me(),
                o.q.fromNumberAsync(i, 1, s, function() {
                    o.q.subtract(Ce.ONE).gcda(a, function(f) {
                        f.compareTo(Ce.ONE) == 0 && o.q.isProbablePrime(10) ? setTimeout(c, 0) : setTimeout(u, 0)
                    })
                })
            }
              , d = function() {
                o.p = Me(),
                o.p.fromNumberAsync(e - i, 1, s, function() {
                    o.p.subtract(Ce.ONE).gcda(a, function(f) {
                        f.compareTo(Ce.ONE) == 0 && o.p.isProbablePrime(10) ? setTimeout(u, 0) : setTimeout(d, 0)
                    })
                })
            };
            setTimeout(d, 0)
        };
        setTimeout(l, 0)
    }
    ,
    t.prototype.sign = function(e, r, n) {
        var s = Dy(n)
          , i = s + r(e).toString()
          , a = My(i, this.n.bitLength() / 4);
        if (a == null)
            return null;
        var o = this.doPrivate(a);
        if (o == null)
            return null;
        var l = o.toString(16);
        return l.length & 1 ? "0" + l : l
    }
    ,
    t.prototype.verify = function(e, r, n) {
        var s = Ke(r, 16)
          , i = this.doPublic(s);
        if (i == null)
            return null;
        var a = i.toString(16).replace(/^1f+00/, "")
          , o = Oy(a);
        return o == n(e).toString()
    }
    ,
    t
}();




var zc = function(t) {
    ky(e, t);
    function e(r) {
        var n = t.call(this) || this;
        return r && (typeof r == "string" ? n.parseKey(r) : (e.hasPrivateKeyProperty(r) || e.hasPublicKeyProperty(r)) && n.parsePropertiesFrom(r)),
        n
    }
    return e.prototype.parseKey = function(r) {
        try {
            var n = 0
              , s = 0
              , i = /^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/
              , a = i.test(r) ? my.decode(r) : Oo.unarmor(r)
              , o = xy.decode(a);
            if (o.sub.length === 3 && (o = o.sub[2].sub[0]),
            o.sub.length === 9) {
                n = o.sub[1].getHexStringValue(),
                this.n = Ke(n, 16),
                s = o.sub[2].getHexStringValue(),
                this.e = parseInt(s, 16);
                var l = o.sub[3].getHexStringValue();
                this.d = Ke(l, 16);
                var c = o.sub[4].getHexStringValue();
                this.p = Ke(c, 16);
                var u = o.sub[5].getHexStringValue();
                this.q = Ke(u, 16);
                var d = o.sub[6].getHexStringValue();
                this.dmp1 = Ke(d, 16);
                var f = o.sub[7].getHexStringValue();
                this.dmq1 = Ke(f, 16);
                var p = o.sub[8].getHexStringValue();
                this.coeff = Ke(p, 16)
            } else if (o.sub.length === 2) {
                var g = o.sub[1]
                  , h = g.sub[0];
                n = h.sub[0].getHexStringValue(),
                this.n = Ke(n, 16),
                s = h.sub[1].getHexStringValue(),
                this.e = parseInt(s, 16)
            } else
                return !1;
            return !0
        } catch {
            return !1
        }
    }
    ,
    e.prototype.getPrivateBaseKey = function() {
        var r = {
            array: [new J.asn1.DERInteger({
                int: 0
            }), new J.asn1.DERInteger({
                bigint: this.n
            }), new J.asn1.DERInteger({
                int: this.e
            }), new J.asn1.DERInteger({
                bigint: this.d
            }), new J.asn1.DERInteger({
                bigint: this.p
            }), new J.asn1.DERInteger({
                bigint: this.q
            }), new J.asn1.DERInteger({
                bigint: this.dmp1
            }), new J.asn1.DERInteger({
                bigint: this.dmq1
            }), new J.asn1.DERInteger({
                bigint: this.coeff
            })]
        }
          , n = new J.asn1.DERSequence(r);
        return n.getEncodedHex()
    }
    ,
    e.prototype.getPrivateBaseKeyB64 = function() {
        return ei(this.getPrivateBaseKey())
    }
    ,
    e.prototype.getPublicBaseKey = function() {
        var r = new J.asn1.DERSequence({
            array: [new J.asn1.DERObjectIdentifier({
                oid: "1.2.840.113549.1.1.1"
            }), new J.asn1.DERNull]
        })
          , n = new J.asn1.DERSequence({
            array: [new J.asn1.DERInteger({
                bigint: this.n
            }), new J.asn1.DERInteger({
                int: this.e
            })]
        })
          , s = new J.asn1.DERBitString({
            hex: "00" + n.getEncodedHex()
        })
          , i = new J.asn1.DERSequence({
            array: [r, s]
        });
        return i.getEncodedHex()
    }
    ,
    e.prototype.getPublicBaseKeyB64 = function() {
        return ei(this.getPublicBaseKey())
    }
    ,
    e.wordwrap = function(r, n) {
        if (n = n || 64,
        !r)
            return r;
        var s = "(.{1," + n + `})( +|$
?)|(.{1,` + n + "})";
        return r.match(RegExp(s, "g")).join(`
`)
    }
    ,
    e.prototype.getPrivateKey = function() {
        var r = `-----BEGIN RSA PRIVATE KEY-----
`;
        return r += e.wordwrap(this.getPrivateBaseKeyB64()) + `
`,
        r += "-----END RSA PRIVATE KEY-----",
        r
    }
    ,
    e.prototype.getPublicKey = function() {
        var r = `-----BEGIN PUBLIC KEY-----
`;
        return r += e.wordwrap(this.getPublicBaseKeyB64()) + `
`,
        r += "-----END PUBLIC KEY-----",
        r
    }
    ,
    e.hasPublicKeyProperty = function(r) {
        return r = r || {},
        r.hasOwnProperty("n") && r.hasOwnProperty("e")
    }
    ,
    e.hasPrivateKeyProperty = function(r) {
        return r = r || {},
        r.hasOwnProperty("n") && r.hasOwnProperty("e") && r.hasOwnProperty("d") && r.hasOwnProperty("p") && r.hasOwnProperty("q") && r.hasOwnProperty("dmp1") && r.hasOwnProperty("dmq1") && r.hasOwnProperty("coeff")
    }
    ,
    e.prototype.parsePropertiesFrom = function(r) {
        this.n = r.n,
        this.e = r.e,
        r.hasOwnProperty("d") && (this.d = r.d,
        this.p = r.p,
        this.q = r.q,
        this.dmp1 = r.dmp1,
        this.dmq1 = r.dmq1,
        this.coeff = r.coeff)
    }
    ,
    e
}(Py);



var Ny = function() {
    function t(e) {
        e = e || {},
        this.default_key_size = e.default_key_size ? parseInt(e.default_key_size, 10) : 1024,
        this.default_public_exponent = e.default_public_exponent || "010001",
        this.log = e.log || !1,
        this.key = null
    }
    return t.prototype.setKey = function(e) {
        this.log && this.key && console.warn("A key was already set, overriding existing."),
        this.key = new zc(e)
    }
    ,
    t.prototype.setPrivateKey = function(e) {
        this.setKey(e)
    }
    ,
    t.prototype.setPublicKey = function(e) {
        this.setKey(e)
    }
    ,
    t.prototype.decrypt = function(e) {
        try {
            return this.getKey().decrypt(Ac(e))
        } catch {
            return !1
        }
    }
    ,
    t.prototype.encrypt = function(e) {
        try {
            return ei(this.getKey().encrypt(e))
        } catch {
            return !1
        }
    }
    ,
    t.prototype.sign = function(e, r, n) {
        try {
            return ei(this.getKey().sign(e, r, n))
        } catch {
            return !1
        }
    }
    ,
    t.prototype.verify = function(e, r, n) {
        try {
            return this.getKey().verify(e, Ac(r), n)
        } catch {
            return !1
        }
    }
    ,
    t.prototype.getKey = function(e) {
        if (!this.key) {
            if (this.key = new zc,
            e && {}.toString.call(e) === "[object Function]") {
                this.key.generateAsync(this.default_key_size, this.default_public_exponent, e);
                return
            }
            this.key.generate(this.default_key_size, this.default_public_exponent)
        }
        return this.key
    }
    ,
    t.prototype.getPrivateKey = function() {
        return this.getKey().getPrivateKey()
    }
    ,
    t.prototype.getPrivateKeyB64 = function() {
        return this.getKey().getPrivateBaseKeyB64()
    }
    ,
    t.prototype.getPublicKey = function() {
        return this.getKey().getPublicKey()
    }
    ,
    t.prototype.getPublicKeyB64 = function() {
        return this.getKey().getPublicBaseKeyB64()
    }
    ,
    t
}();




function Jo(t, e) {
    const r = new Ny({});
//     debugger;
    return r.setPublicKey(t),
    r.encrypt(e)
}




let t = '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArbBaNEIC630Fg+SiPJPV\nDh3u/nOCsHzY3Rmi5x2qzYR4A116PzYHzKRKHf/4tfhZPNzu84zK2nBbZbBIKk4s\n8l//GwQ7ZqULjfduoWwo5QRi80ISaoC+7+tb3YMy/niiKfUd2725avwtJjJJ3PZ4\n26yjTQ9E4giOmJ0k7tI7gSOa3BbL5SuLMICwGvwOU3xdISKKaTwzkit3I4nVTzF3\nkYKG7PI3HEJhybI/IAl+GleksO6Zzf1P/l8j/oge5KITeJnC0QJtR8VGkW15pR0C\nf9IgTJZ34KGXEYkaVqnFO9YvMJjM5BYG80+pQCRCV0+rzHy5nNE93oOM3aZkMjE8\nmwIDAQAB\n-----END PUBLIC KEY-----';

let e = '123456';

let angdh = Jo(t,e);



console.log(angdh)