!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.JSEncrypt={})}(this,function(j){"use strict";function a(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function L(t,e){return t&e}function h(t,e){return t|e}function H(t,e){return t^e}function C(t,e){return t&~e}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function f(t){for(var e,i="",r=0;r+3<=t.length;r+=3)e=parseInt(t.substring(r,r+3),16),i+=o.charAt(e>>6)+o.charAt(63&e);for(r+1==t.length?(e=parseInt(t.substring(r,r+1),16),i+=o.charAt(e<<2)):r+2==t.length&&(e=parseInt(t.substring(r,r+2),16),i+=o.charAt(e>>2)+o.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=(e+=a(r))+a(s>>2),r=3&s,3):(e=(e+=a(r<<2|s>>4))+a(15&s),0))}return 1==i&&(e+=a(r<<2)),e}function K(t){for(var e=[],i=0;i>>4).toString(16)),e.push((15&t[i]).toString(16));return e.join("")}var c,t=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])});var l,U=function(t){if(void 0===c){var e="0123456789ABCDEF",i=" \f\n\r\t\xa0\u2028\u2029";for(c={},o=0;o<16;++o)c[e.charAt(o)]=o;for(e=e.toLowerCase(),o=10;o<16;++o)c[e.charAt(o)]=o;for(o=0;o>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=F.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 F.decode(t)}},p=1e13,g=(e.prototype.mulAdd=function(t,e){for(var i,r=this.buf,n=r.length,s=0;se?t.substring(0,e)+"\u2026":t}i.prototype.get=function(t){if((t=void 0===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]},i.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},i.prototype.hexDump=function(t,e,i){for(var r="",n=t;n>u&1?"1":"0";if(s.length>i)return n+d(s,i)}return n+s},i.prototype.parseOctetString=function(t,e,i){if(this.isASCII(t,e))return d(this.parseStringISO(t,e),i);var r=e-t,n="("+r+" byte)\n";(i/=2)i)return d(r,i);n=new g,s=0}}return 0>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){for(var i=new g;e=t.get(),i.mulAdd(128,127&e),128&e;);this.tagNumber=i.simplify()}}var m=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Q=(1<<26)/m[m.length-1],v=(b.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<>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)),(n=0>24},b.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},b.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},b.prototype.toByteArray=function(){var t,e=this.t,i=[],r=(i[0]=this.s,this.DB-e*this.DB%8),n=0;if(0>r)!=(this.s&this.DM)>>r&&(i[n++]=t|this.s<>(r+=this.DB-8)):(t=this[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),0!=(128&t)&&(t|=-256),0==n&&(128&this.s)!=(128&t)&&++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));return this.s<0?this.t*this.DB:-1},b.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i=this.t?0!=this.s:0!=(this[e]&1<>i-a&u:(f=(t[p]&(1<>this.DB+i-a)),h=n;0==(1&f);)f>>=1,--h;if((i-=h)<0&&(i+=this.DB,--p),g)o[f].copyTo(r),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/r,f=(1<=i&&(this.dMultiply(r),this.dAddOffset(o,0),o=s=0))}0t&&this.subTo(b.ONE.shiftLeft(t-1),this);else{var i=[],r=7&t;i.length=1+(t>>3),e.nextBytes(i),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]}},b.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=m.length),S()),s=0;st&&n.subTo(b.ONE.shiftLeft(t-1),n),n.isProbablePrime(e)?setTimeout(function(){r()},0):setTimeout(s,0)},setTimeout(s,0)):(i=7&t,(o=[]).length=1+(t>>3),e.nextBytes(o),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)},s.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},s.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var X=s;function s(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<2*this.m.t?t.mod(this.m):t.compareTo(this.m)<0?t:(e=S(),t.copyTo(e),this.reduce(e),e)},T.prototype.revert=function(t){return t},T.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)},T.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},T.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var W=T;function T(t){this.m=t,this.r2=S(),this.q3=S(),v.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}function S(){return new v(null)}function E(t,e){return new v(t,e)}v.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},v.prototype.DB=28,v.prototype.DM=268435455,v.prototype.DV=1<<28;v.prototype.FV=Math.pow(2,52),v.prototype.F1=24,v.prototype.F2=4;for(var D=[],w="0".charCodeAt(0),x=0;x<=9;++x)D[w++]=x;for(w="a".charCodeAt(0),x=10;x<36;++x)D[w++]=x;for(w="A".charCodeAt(0),x=10;x<36;++x)D[w++]=x;function tt(t,e){t=D[t.charCodeAt(e)];return null==t?-1:t}function B(t){var e=S();return e.fromInt(t),e}function R(t){var e,i=1;return 0!=(e=t>>>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}v.ZERO=B(0),v.ONE=B(1);it.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},it.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]};var et=it;function it(){this.i=0,this.j=0,this.S=[]}var A;if(null==(O=null))for(var O=[],V=0,rt=new Uint32Array(256),nt=0,st=rt.length;nt>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 ht,o=[];2>3);return null==t||null==(t=this.doPublic(t))?null:0==(1&(t=t.toString(16)).length)?t:"0"+t},I.prototype.setPrivate=function(t,e,i){null!=t&&null!=e&&0>1,n=(this.e=parseInt(e,16),new v(e,16));;){for(;this.p=new v(t-r,1,i),0!=this.p.subtract(v.ONE).gcd(n).compareTo(v.ONE)||!this.p.isProbablePrime(10););for(;this.q=new v(r,1,i),0!=this.q.subtract(v.ONE).gcd(n).compareTo(v.ONE)||!this.q.isProbablePrime(10););this.p.compareTo(this.q)<=0&&(s=this.p,this.p=this.q,this.q=s);var s=this.p.subtract(v.ONE),o=this.q.subtract(v.ONE),h=s.multiply(o);if(0==h.gcd(n).compareTo(v.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}}},I.prototype.decrypt=function(t){t=E(t,16),t=this.doPrivate(t);if(null==t)return null;for(var e=this.n.bitLength()+7>>3,i=t.toByteArray(),r=0;r=i.length)return null;for(var n="";++r>1,h=(this.e=parseInt(e,16),new v(e,16)),a=this,u=function(){function e(){a.p=S(),a.p.fromNumberAsync(t-o,1,s,function(){a.p.subtract(v.ONE).gcda(h,function(t){0==t.compareTo(v.ONE)&&a.p.isProbablePrime(10)?setTimeout(r,0):setTimeout(e,0)})})}var i=function(){a.p.compareTo(a.q)<=0&&(t=a.p,a.p=a.q,a.q=t);var t=a.p.subtract(v.ONE),e=a.q.subtract(v.ONE),i=t.multiply(e);0==i.gcd(h).compareTo(v.ONE)?(a.n=a.p.multiply(a.q),a.d=h.modInverse(i),a.dmp1=a.d.mod(t),a.dmq1=a.d.mod(e),a.coeff=a.q.modInverse(a.p),setTimeout(function(){n()},0)):setTimeout(u,0)},r=function(){a.q=S(),a.q.fromNumberAsync(o,1,s,function(){a.q.subtract(v.ONE).gcda(h,function(t){0==t.compareTo(v.ONE)&&a.q.isProbablePrime(10)?setTimeout(i,0):setTimeout(r,0)})})};setTimeout(e,0)};setTimeout(u,0)};var ut=I;function I(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}var ct,ft,N={lang:{extend:function(t,e,i){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");function r(){}if(r.prototype=e.prototype,t.prototype=new r,(t.prototype.constructor=t).superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),i){for(var n in i)t.prototype[n]=i[n];var e=function(){},s=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(e=function(t,e){for(n=0;n=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){t=new Date(Date.UTC(t,e-1,i,r,n,s,0));this.setByDate(t)},this.getFreshValueHex=function(){return this.hV}},N.lang.extend(P.asn1.DERAbstractTime,P.asn1.ASN1Object),P.asn1.DERAbstractStructured=function(t){P.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)},N.lang.extend(P.asn1.DERAbstractStructured,P.asn1.ASN1Object),P.asn1.DERBoolean=function(){P.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},N.lang.extend(P.asn1.DERBoolean,P.asn1.ASN1Object),P.asn1.DERInteger=function(t){P.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=P.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){t=new v(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))},N.lang.extend(P.asn1.DERInteger,P.asn1.ASN1Object),P.asn1.DERBitString=function(t){var e;void 0!==t&&void 0!==t.obj&&(e=P.asn1.ASN1Util.newObject(t.obj),t.hex="00"+e.getEncodedHex()),P.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>3)-11;try{var r="";return t.length>i?(t.match(/.{1,50}/g).forEach(function(t){t=e.encrypt(t);r+=t}),f(r)):f(e.encrypt(t))}catch(t){return!1}},q.prototype.encryptLong2=function(t){var e=this.getKey();try{for(var i,r="",n=new Array,s=(n.push(0),0),o=t.length,h=0,a=0;a>3;try{var r=u(t),n=(console.log(r),r.length,"");return r.length>i?(r.match(/.{1,256}/g).forEach(function(t){t=e.decrypt(t);n+=t}),n):e.decrypt(u(t))}catch(t){return!1}},q.prototype.decryptLong2=function(t){var e=this.getKey();try{for(var i,r="",n=function(t){for(var e=[],i=0;i