!function(t){function r(i){var t=g,r=t.biDivideByRadixPower(i,this.k-1),e=t.biMultiply(r,this.mu),s=t.biDivideByRadixPower(e,this.k+1),n=t.biModuloByRadixPower(i,this.k+1),d=t.biMultiply(s,this.modulus),o=t.biModuloByRadixPower(d,this.k+1),u=t.biSubtract(n,o);u.isNeg&&(u=t.biAdd(u,this.bkplus1));for(var a=t.biCompare(u,this.modulus)>=0;a;)u=t.biSubtract(u,this.modulus),a=t.biCompare(u,this.modulus)>=0;return u}function e(i,t){var r=g.biMultiply(i,t);return this.modulo(r)}function s(i,t){var r=new c;r.digits[0]=1;for(var e=i,s=t;;){if(0!=(1&s.digits[0])&&(r=this.multiplyMod(r,e)),s=g.biShiftRight(s,1),0==s.digits[0]&&0==g.biHighIndex(s))break;e=this.multiplyMod(e,e)}return r}if("undefined"==typeof t.RSAUtils)var g=t.RSAUtils={};var n,d,o,u,a=16,b=a,l=65536,h=l>>>1,f=l*l,v=l-1,c=t.BigInt=function(i){this.digits="boolean"==typeof i&&1==i?null:d.slice(0),this.isNeg=!1};g.setMaxDigits=function(i){n=i,d=new Array(n);for(var t=0;t<d.length;t++)d[t]=0;o=new c,u=new c,u.digits[0]=1},g.setMaxDigits(20);var N=15;g.biFromNumber=function(i){var t=new c;t.isNeg=0>i,i=Math.abs(i);for(var r=0;i>0;)t.digits[r++]=i&v,i=Math.floor(i/l);return t};var m=g.biFromNumber(1e15);g.biFromDecimal=function(i){for(var t,r="-"==i.charAt(0),e=r?1:0;e<i.length&&"0"==i.charAt(e);)++e;if(e==i.length)t=new c;else{var s=i.length-e,n=s%N;for(0==n&&(n=N),t=g.biFromNumber(Number(i.substr(e,n))),e+=n;e<i.length;)t=g.biAdd(g.biMultiply(t,m),g.biFromNumber(Number(i.substr(e,N)))),e+=N;t.isNeg=r}return t},g.biCopy=function(i){var t=new c(!0);return t.digits=i.digits.slice(0),t.isNeg=i.isNeg,t},g.reverseStr=function(i){for(var t="",r=i.length-1;r>-1;--r)t+=i.charAt(r);return t};var M=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];g.biToString=function(i,t){var r=new c;r.digits[0]=t;for(var e=g.biDivideModulo(i,r),s=M[e[1].digits[0]];1==g.biCompare(e[0],o);)e=g.biDivideModulo(e[0],r),digit=e[1].digits[0],s+=M[e[1].digits[0]];return(i.isNeg?"-":"")+g.reverseStr(s)},g.biToDecimal=function(i){var t=new c;t.digits[0]=10;for(var r=g.biDivideModulo(i,t),e=String(r[1].digits[0]);1==g.biCompare(r[0],o);)r=g.biDivideModulo(r[0],t),e+=String(r[1].digits[0]);return(i.isNeg?"-":"")+g.reverseStr(e)};var y=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];g.digitToHex=function(t){var r=15,e="";for(i=0;4>i;++i)e+=y[t&r],t>>>=4;return g.reverseStr(e)},g.biToHex=function(i){for(var t="",r=(g.biHighIndex(i),g.biHighIndex(i));r>-1;--r)t+=g.digitToHex(i.digits[r]);return t},g.charToHex=function(i){var t,r=48,e=r+9,s=97,g=s+25,n=65,d=90;return t=i>=r&&e>=i?i-r:i>=n&&d>=i?10+i-n:i>=s&&g>=i?10+i-s:0},g.hexToDigit=function(i){for(var t=0,r=Math.min(i.length,4),e=0;r>e;++e)t<<=4,t|=g.charToHex(i.charCodeAt(e));return t},g.biFromHex=function(i){for(var t=new c,r=i.length,e=r,s=0;e>0;e-=4,++s)t.digits[s]=g.hexToDigit(i.substr(Math.max(e-4,0),Math.min(e,4)));return t},g.biFromString=function(i,t){var r="-"==i.charAt(0),e=r?1:0,s=new c,n=new c;n.digits[0]=1;for(var d=i.length-1;d>=e;d--){var o=i.charCodeAt(d),u=g.charToHex(o),a=g.biMultiplyDigit(n,u);s=g.biAdd(s,a),n=g.biMultiplyDigit(n,t)}return s.isNeg=r,s},g.biDump=function(i){return(i.isNeg?"-":"")+i.digits.join(" ")},g.biAdd=function(i,t){var r;if(i.isNeg!=t.isNeg)t.isNeg=!t.isNeg,r=g.biSubtract(i,t),t.isNeg=!t.isNeg;else{r=new c;for(var e,s=0,n=0;n<i.digits.length;++n)e=i.digits[n]+t.digits[n]+s,r.digits[n]=e%l,s=Number(e>=l);r.isNeg=i.isNeg}return r},g.biSubtract=function(i,t){var r;if(i.isNeg!=t.isNeg)t.isNeg=!t.isNeg,r=g.biAdd(i,t),t.isNeg=!t.isNeg;else{r=new c;var e,s;s=0;for(var n=0;n<i.digits.length;++n)e=i.digits[n]-t.digits[n]+s,r.digits[n]=e%l,r.digits[n]<0&&(r.digits[n]+=l),s=0-Number(0>e);if(-1==s){s=0;for(var n=0;n<i.digits.length;++n)e=0-r.digits[n]+s,r.digits[n]=e%l,r.digits[n]<0&&(r.digits[n]+=l),s=0-Number(0>e);r.isNeg=!i.isNeg}else r.isNeg=i.isNeg}return r},g.biHighIndex=function(i){for(var t=i.digits.length-1;t>0&&0==i.digits[t];)--t;return t},g.biNumBits=function(i){var t,r=g.biHighIndex(i),e=i.digits[r],s=(r+1)*b;for(t=s;t>s-b&&0==(32768&e);--t)e<<=1;return t},g.biMultiply=function(i,t){for(var r,e,s,n=new c,d=g.biHighIndex(i),o=g.biHighIndex(t),u=0;o>=u;++u){for(r=0,s=u,j=0;d>=j;++j,++s)e=n.digits[s]+i.digits[j]*t.digits[u]+r,n.digits[s]=e&v,r=e>>>a;n.digits[u+d+1]=r}return n.isNeg=i.isNeg!=t.isNeg,n},g.biMultiplyDigit=function(i,t){var r,e,s;result=new c,r=g.biHighIndex(i),e=0;for(var n=0;r>=n;++n)s=result.digits[n]+i.digits[n]*t+e,result.digits[n]=s&v,e=s>>>a;return result.digits[1+r]=e,result},g.arrayCopy=function(i,t,r,e,s){for(var g=Math.min(t+s,i.length),n=t,d=e;g>n;++n,++d)r[d]=i[n]};var p=[0,32768,49152,57344,61440,63488,64512,65024,65280,65408,65472,65504,65520,65528,65532,65534,65535];g.biShiftLeft=function(i,t){var r=Math.floor(t/b),e=new c;g.arrayCopy(i.digits,0,e.digits,r,e.digits.length-r);for(var s=t%b,n=b-s,d=e.digits.length-1,o=d-1;d>0;--d,--o)e.digits[d]=e.digits[d]<<s&v|(e.digits[o]&p[s])>>>n;return e.digits[0]=e.digits[d]<<s&v,e.isNeg=i.isNeg,e};var w=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];g.biShiftRight=function(i,t){var r=Math.floor(t/b),e=new c;g.arrayCopy(i.digits,r,e.digits,0,i.digits.length-r);for(var s=t%b,n=b-s,d=0,o=d+1;d<e.digits.length-1;++d,++o)e.digits[d]=e.digits[d]>>>s|(e.digits[o]&w[s])<<n;return e.digits[e.digits.length-1]>>>=s,e.isNeg=i.isNeg,e},g.biMultiplyByRadixPower=function(i,t){var r=new c;return g.arrayCopy(i.digits,0,r.digits,t,r.digits.length-t),r},g.biDivideByRadixPower=function(i,t){var r=new c;return g.arrayCopy(i.digits,t,r.digits,0,r.digits.length-t),r},g.biModuloByRadixPower=function(i,t){var r=new c;return g.arrayCopy(i.digits,0,r.digits,0,t),r},g.biCompare=function(i,t){if(i.isNeg!=t.isNeg)return 1-2*Number(i.isNeg);for(var r=i.digits.length-1;r>=0;--r)if(i.digits[r]!=t.digits[r])return i.isNeg?1-2*Number(i.digits[r]>t.digits[r]):1-2*Number(i.digits[r]<t.digits[r]);return 0},g.biDivideModulo=function(i,t){var r,e,s=g.biNumBits(i),n=g.biNumBits(t),d=t.isNeg;if(n>s)return i.isNeg?(r=g.biCopy(u),r.isNeg=!t.isNeg,i.isNeg=!1,t.isNeg=!1,e=biSubtract(t,i),i.isNeg=!0,t.isNeg=d):(r=new c,e=g.biCopy(i)),[r,e];r=new c,e=i;for(var o=Math.ceil(n/b)-1,a=0;t.digits[o]<h;)t=g.biShiftLeft(t,1),++a,++n,o=Math.ceil(n/b)-1;e=g.biShiftLeft(e,a),s+=a;for(var N=Math.ceil(s/b)-1,m=g.biMultiplyByRadixPower(t,N-o);-1!=g.biCompare(e,m);)++r.digits[N-o],e=g.biSubtract(e,m);for(var M=N;M>o;--M){var y=M>=e.digits.length?0:e.digits[M],p=M-1>=e.digits.length?0:e.digits[M-1],w=M-2>=e.digits.length?0:e.digits[M-2],x=o>=t.digits.length?0:t.digits[o],S=o-1>=t.digits.length?0:t.digits[o-1];r.digits[M-o-1]=y==x?v:Math.floor((y*l+p)/x);for(var D=r.digits[M-o-1]*(x*l+S),H=y*f+(p*l+w);D>H;)--r.digits[M-o-1],D=r.digits[M-o-1]*(x*l|S),H=y*l*l+(p*l+w);m=g.biMultiplyByRadixPower(t,M-o-1),e=g.biSubtract(e,g.biMultiplyDigit(m,r.digits[M-o-1])),e.isNeg&&(e=g.biAdd(e,m),--r.digits[M-o-1])}return e=g.biShiftRight(e,a),r.isNeg=i.isNeg!=d,i.isNeg&&(r=d?g.biAdd(r,u):g.biSubtract(r,u),t=g.biShiftRight(t,a),e=g.biSubtract(t,e)),0==e.digits[0]&&0==g.biHighIndex(e)&&(e.isNeg=!1),[r,e]},g.biDivide=function(i,t){return g.biDivideModulo(i,t)[0]},g.biModulo=function(i,t){return g.biDivideModulo(i,t)[1]},g.biMultiplyMod=function(i,t,r){return g.biModulo(g.biMultiply(i,t),r)},g.biPow=function(i,t){for(var r=u,e=i;;){if(0!=(1&t)&&(r=g.biMultiply(r,e)),t>>=1,0==t)break;e=g.biMultiply(e,e)}return r},g.biPowMod=function(i,t,r){for(var e=u,s=i,n=t;;){if(0!=(1&n.digits[0])&&(e=g.biMultiplyMod(e,s,r)),n=g.biShiftRight(n,1),0==n.digits[0]&&0==g.biHighIndex(n))break;s=g.biMultiplyMod(s,s,r)}return e},t.BarrettMu=function(i){this.modulus=g.biCopy(i),this.k=g.biHighIndex(this.modulus)+1;var t=new c;t.digits[2*this.k]=1,this.mu=g.biDivide(t,this.modulus),this.bkplus1=new c,this.bkplus1.digits[this.k+1]=1,this.modulo=r,this.multiplyMod=e,this.powMod=s};var x=function(i,r,e){var s=g;this.e=s.biFromHex(i),this.d=s.biFromHex(r),this.m=s.biFromHex(e),this.chunkSize=2*s.biHighIndex(this.m),this.radix=16,this.barrett=new t.BarrettMu(this.m)};g.getKeyPair=function(i,t,r){return new x(i,t,r)},"undefined"==typeof t.twoDigit&&(t.twoDigit=function(i){return(10>i?"0":"")+String(i)}),g.encryptedString=function(i,t){for(var r=[],e=t.length,s=0;e>s;)r[s]=t.charCodeAt(s),s++;for(;r.length%i.chunkSize!=0;)r[s++]=0;var n,d,o,u=r.length,a="";for(s=0;u>s;s+=i.chunkSize){for(o=new c,n=0,d=s;d<s+i.chunkSize;++n)o.digits[n]=r[d++],o.digits[n]+=r[d++]<<8;var b=i.barrett.powMod(o,i.e),l=16==i.radix?g.biToHex(b):g.biToString(b,i.radix);a+=l+" "}return a.substring(0,a.length-1)},g.decryptedString=function(i,t){var r,e,s,n=t.split(" "),d="";for(r=0;r<n.length;++r){var o;for(o=16==i.radix?g.biFromHex(n[r]):g.biFromString(n[r],i.radix),s=i.barrett.powMod(o,i.d),e=0;e<=g.biHighIndex(s);++e)d+=String.fromCharCode(255&s.digits[e],s.digits[e]>>8)}return 0==d.charCodeAt(d.length-1)&&(d=d.substring(0,d.length-1)),d},g.setMaxDigits(130)}(window);