"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t,e){"object"==("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.JSEncrypt={})}(window,function(t){var e="0123456789abcdefghijklmnopqrstuvwxyz";function a(t){return e.charAt(t)}function i(t,e){return t&e}function o(t,e){return t|e}function r(t,e){return t^e}function n(t,e){return t&~e}var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function s(t){for(var e,i="",r=0;r+3<=t.length;r+=3)e=parseInt(t.substring(r,r+3),16),i+=h.charAt(e>>6)+h.charAt(63&e);for(r+1==t.length?(e=parseInt(t.substring(r,r+1),16),i+=h.charAt(e<<2)):r+2==t.length&&(e=parseInt(t.substring(r,r+2),16),i+=h.charAt(e>>2)+h.charAt((3&e)<<4));0<(3&i.length);)i+="=";return i}function u(t){for(var e="",i=0,r=0,n=0;n>2),r=3&s,1):1==i?(e+=a(r<<2|s>>4),r=15&s,2):2==i?(e+=a(r),e+=a(s>>2),r=3&s,3):(e+=a(r<<2|s>>4),e+=a(15&s),0))}return 1==i&&(e+=a(r<<2)),e}var c,f,l=function(t,e){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},p={decode:function(t){if(void 0===f){var e="= \f\n\r\t \u2028\u2029";for(f=Object.create(null),s=0;s<64;++s)f["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(s)]=s;for(s=0;s>16,i[i.length]=r>>8&255,i[i.length]=255&r,n=r=0):r<<=6}}switch(n){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=r>>10;break;case 3:i[i.length]=r>>16,i[i.length]=r>>8&255}return i},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=p.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return p.decode(t)}},g=1e13,d=(b.prototype.mulAdd=function(t,e){for(var i,r=this.buf,n=r.length,s=0;se&&(t=t.substring(0,e)+y),t}var S=(C.prototype.get=function(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]},C.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},C.prototype.hexDump=function(t,e,i){for(var r="",n=t;n>u&1?"1":"0";if(s.length>i)return n+T(s,i)}return n+s},C.prototype.parseOctetString=function(t,e,i){if(this.isASCII(t,e))return T(this.parseStringISO(t,e),i);var r=e-t,n="("+r+" byte)\n";(i/=2)i)return T(r,i);n=new d,s=0}}return 0>h)&&(n=!0,s=a(i));0<=o;)h>(h+=this.DB-e)):(i=this[o]>>(h-=e)&r,h<=0&&(h+=this.DB,--o)),0>24},L.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},L.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},L.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var i,r=this.DB-t*this.DB%8,n=0;if(0>r)!=(this.s&this.DM)>>r&&(e[n++]=i|this.s<>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(0>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}(this[t]);return this.s<0?this.t*this.DB:-1},L.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i=this.t?0!=this.s:0!=(this[e]&1<>n-a&u:(f=(t[p]&(1<>this.DB+n-a)),h=i;0==(1&f);)f>>=1,--h;if((n-=h)<0&&(n+=this.DB,--p),g)o[f].copyTo(s),g=!1;else{for(;1this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&+t[0])&&(this.s=-1,0>r|o,o=(this[h]&n)<=this.t)e.t=0;else{var r=t%this.DB,n=this.DB-r,s=(1<>r;for(var o=i+1;o>r;0>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:0=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}0>this.F2:0),c=this.FV/n,f=(1<=i&&(this.dMultiply(r),this.dAddOffset(o,0),o=s=0))}0t&&this.subTo(L.ONE.shiftLeft(t-1),this);else{var r=[],i=7&t;r.length=1+(t>>3),e.nextBytes(r),0>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r+=t.s}e.s=r<0?-1:0,0=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},L.prototype.multiplyLowerTo=function(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;0>1)&&(t=w.length);for(var n=H(),s=0;se&&n.subTo(L.ONE.shiftLeft(e-1),n),n.isProbablePrime(i)?setTimeout(function(){r()},0):setTimeout(t,0)},setTimeout(s,0)):(t=7&e,(s=[]).length=1+(e>>3),i.nextBytes(s),0>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),0<=t.compareTo(this.m)&&t.subTo(this.m,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},N),V=(I.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=H();return t.copyTo(e),this.reduce(e),e},I.prototype.revert=function(t){return t},I.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);0<=t.compareTo(this.m);)t.subTo(this.m,t)},I.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},I.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},I);function I(t){this.m=t,this.r2=H(),this.q3=H(),B.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}function N(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){for(var i=new d;e=t.get(),i.mulAdd(128,127&e),128&e;);this.tagNumber=i.simplify()}}function j(t,e,i,r,n){if(!(r instanceof D))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=n}function C(t,e){this.hexDigits="0123456789ABCDEF",t instanceof C?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}function H(){return new B(null)}function K(t,e){return new B(t,e)}nt="Microsoft Internet Explorer"==navigator.appName?(B.prototype.am=function(t,e,i,r,n,s){for(var o=32767&e,h=e>>15;0<=--s;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;n=((a=o*a+((32767&c)<<15)+i[r]+(1073741823&n))>>>30)+(c>>>15)+h*u+(n>>>30),i[r++]=1073741823&a}return n},30):"Netscape"!=navigator.appName?(B.prototype.am=function(t,e,i,r,n,s){for(;0<=--s;){var o=e*this[t++]+i[r]+n;n=Math.floor(o/67108864),i[r++]=67108863&o}return n},26):(B.prototype.am=function(t,e,i,r,n,s){for(var o=16383&e,h=e>>14;0<=--s;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;n=((a=o*a+((16383&c)<<14)+i[r]+n)>>28)+(c>>14)+h*u,i[r++]=268435455&a}return n},28),B.prototype.DB=nt,B.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}B.ZERO=z(0),B.ONE=z(1);var G=(Y.prototype.init=function(t){for(var e,i,r=0;r<256;++r)this.S[r]=r;for(r=e=0;r<256;++r)e=e+this.S[r]+t[r%t.length]&255,i=this.S[r],this.S[r]=this.S[e],this.S[e]=i;this.i=0,this.j=0},Y.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},Y);function Y(){this.i=0,this.j=0,this.S=[]}var $,Q,J=256,X=null;if(null==X){X=[];var W=void(Q=0);if(window.crypto&&window.crypto.getRandomValues){var tt=new Uint32Array(256);for(window.crypto.getRandomValues(tt),W=0;W>6|192):(i[--e]=63&n|128,i[--e]=n>>6&63|128,i[--e]=n>>12|224)}i[--e]=0;for(var s=new it,o=[];2>3);if(null==t)return null;t=this.doPublic(t);if(null==t)return null;t=t.toString(16);return 0==(1&t.length)?t:"0"+t},st.prototype.encryptLong=function(t){var e=this,i=(this.n.bitLength()+7>>3)-11;try{var r="";return t.length>i?(t.match(/.{1,117}/g).forEach(function(t){t=e.encrypt(t);r+=t}),s(r)):s(this.encrypt(t))}catch(t){return!1}},st.prototype.decryptLong=function(t){var e=this,i=this.n.bitLength()+7>>3;t=u(t);try{if(t.length>i){var r="";return t.match(/.{1,256}/g).forEach(function(t){t=e.decrypt(t);r+=t}),r}return this.decrypt(t)}catch(t){return!1}},st.prototype.setPrivate=function(t,e,i){null!=t&&null!=e&&0>1;this.e=parseInt(e,16);for(var n=new B(e,16);;){for(;this.p=new B(t-r,1,i),0!=this.p.subtract(B.ONE).gcd(n).compareTo(B.ONE)||!this.p.isProbablePrime(10););for(;this.q=new B(r,1,i),0!=this.q.subtract(B.ONE).gcd(n).compareTo(B.ONE)||!this.q.isProbablePrime(10););this.p.compareTo(this.q)<=0&&(h=this.p,this.p=this.q,this.q=h);var s=this.p.subtract(B.ONE),o=this.q.subtract(B.ONE),h=s.multiply(o);if(0==h.gcd(n).compareTo(B.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(h),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(o),this.coeff=this.q.modInverse(this.p);break}}},st.prototype.decrypt=function(t){t=K(t,16),t=this.doPrivate(t);return null==t?null:function(t,e){for(var i=t.toByteArray(),r=0;r=i.length)return null;for(var n="";++r>3)},st.prototype.generateAsync=function(t,e,s){var o=new it,h=t>>1;this.e=parseInt(e,16);var a=new B(e,16),u=this,e=function r(){function e(){u.p.compareTo(u.q)<=0&&(i=u.p,u.p=u.q,u.q=i);var t=u.p.subtract(B.ONE),e=u.q.subtract(B.ONE),i=t.multiply(e);0==i.gcd(a).compareTo(B.ONE)?(u.n=u.p.multiply(u.q),u.d=a.modInverse(i),u.dmp1=u.d.mod(t),u.dmq1=u.d.mod(e),u.coeff=u.q.modInverse(u.p),setTimeout(function(){s()},0)):setTimeout(r,0)}function i(){u.q=H(),u.q.fromNumberAsync(h,1,o,function(){u.q.subtract(B.ONE).gcda(a,function(t){0==t.compareTo(B.ONE)&&u.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(i,0)})})}function n(){u.p=H(),u.p.fromNumberAsync(t-h,1,o,function(){u.p.subtract(B.ONE).gcda(a,function(t){0==t.compareTo(B.ONE)&&u.p.isProbablePrime(10)?setTimeout(i,0):setTimeout(n,0)})})}setTimeout(n,0)};setTimeout(e,0)},st.prototype.sign=function(t,e,i){t=function(t,e){if(e=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,i,r,n,s){s=new Date(Date.UTC(t,e-1,i,r,n,s,0));this.setByDate(s)},this.getFreshValueHex=function(){return this.hV}},et.lang.extend(ht.asn1.DERAbstractTime,ht.asn1.ASN1Object),ht.asn1.DERAbstractStructured=function(t){ht.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},et.lang.extend(ht.asn1.DERAbstractStructured,ht.asn1.ASN1Object),ht.asn1.DERBoolean=function(){ht.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},et.lang.extend(ht.asn1.DERBoolean,ht.asn1.ASN1Object),ht.asn1.DERInteger=function(t){ht.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ht.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){t=new B(String(t),10);this.setByBigInteger(t)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},et.lang.extend(ht.asn1.DERInteger,ht.asn1.ASN1Object),ht.asn1.DERBitString=function(t){var e;void 0!==t&&void 0!==t.obj&&(e=ht.asn1.ASN1Util.newObject(t.obj),t.hex="00"+e.getEncodedHex()),ht.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7