Crypto=typeof Crypto!="undefined"?Crypto:{};Crypto.RSA=(function(){var o=28;var u=1<<o,a=u-1,n=u>>1,h=o>>1,q=(1<<h)-1;var k=Math.log(2);function g(w,v){var y=w.length,B=v.length;if(y<B){return g(v,w)}var x=new Array(y);var A=0,z=0;for(;z<B;z++){A+=w[z]+v[z];x[z]=A&a;A>>>=o}for(;z<y;z++){A+=w[z];x[z]=A&a;A>>>=o}if(A){x[z]=A}return x}function t(w,v){var y=w.length,B=v.length;if(B>y){return[]}if(B==y){if(v[B-1]>w[B-1]){return[]}if(B==1){return[w[0]-v[0]]}}var x=new Array(y);var A=0;for(var z=0;z<B;z++){A+=w[z]-v[z];x[z]=A&a;A>>=o}for(;z<y;z++){A+=w[z];x[z]=A&a;A>>=o}if(A){return[]}if(x[z-1]){return x}while(z>1&&x[z-1]==0){z--}return x.slice(0,z)}function m(w){var v=new Array(w);while(w-->0){v[w]=0}return v}function j(J,I){I=I.concat([0]);var E=J.length,x=I.length;var y,K,w,H,z,D,G,C,B,F,A;var v=m(E+x+1);for(y=0;y<E;y++){w=J[y];if(w){H=0;B=w>>h;C=w&q;z=y;for(K=0;K<x;K++,z++){D=I[K];G=D>>h;D=D&q;F=D*B+C*G;A=F>>h;F&=q;H+=v[z]+C*D+(F<<h);v[z]=H&a;H=(H>>o)+G*B+A}}}y=v.length;if(v[y-1]){return v}while(y>1&&v[y-1]==0){y--}return v.slice(0,y)}function p(w,z,v){var y=0;while(z>=0&&v-->0){y=y*u+w[z--]}return y}function f(C,B){var H=C.length-1,E=B.length-1,D=H-E;if(H<E||H==E&&(C[H]<B[H]||H>0&&C[H]==B[H]&&C[H-1]<B[H-1])){this.q=[0];this.mod=C;return this}if(H==E&&p(C,E,2)/p(B,E,2)<4){var v=0,A;for(;;){A=t(C,B);if(A.length==0){break}C=A;v++}this.q=[v];this.mod=C;return this}var N,M;M=Math.floor(Math.log(B[E])/k)+1;N=o-M;if(N){C=C.concat();B=B.concat();for(L=E;L>0;L--){B[L]=((B[L]<<N)&a)|(B[L-1]>>M)}B[0]=(B[0]<<N)&a;if(C[H]&((a<<M)&a)){C[++H]=0;D++}for(L=H;L>0;L--){C[L]=((C[L]<<N)&a)|(C[L-1]>>M)}C[0]=(C[0]<<N)&a}var L,K,O;var G=m(D+1);var w=m(D).concat(B);for(;;){O=t(C,w);if(O.length==0){break}G[D]++;C=O}var J=B[E],F=p(B,E,2);for(L=H;L>E;L--){var I=L-E-1;if(L>=C.length){G[I]=1}else{if(C[L]==J){G[I]=a}else{G[I]=Math.floor(p(C,L,2)/J)}}var z=p(C,L,3);while(G[I]*F>z){G[I]--}w=w.slice(1);O=t(C,j([G[I]],w));if(O.length==0){G[I]--;O=t(C,j([G[I]],w))}C=O}if(N){for(L=0;L<C.length-1;L++){C[L]=(C[L]>>N)|((C[L+1]<<M)&a)}C[C.length-1]>>=N}H=G.length;while(H>1&&G[H-1]==0){H--}this.q=G.slice(0,H);H=C.length;while(H>1&&C[H-1]==0){H--}this.mod=C.slice(0,H);return this}function c(y,w){var A=0,x;for(var z=y.length-1;z>=0;z--){x=y[z];A=((x>>h)+(A<<h))%w;A=((x&q)+(A<<h))%w}return A}function l(x,v){if(v.length==1){if(x.length==1){return[x[0]%v[0]]}if(v[0]<q){return[c(x,v[0])]}}var w=new f(x,v);return w.mod}function d(E,A,H){var D=E.length-(A.length<<1);if(D>0){return d(E.slice(0,D).concat(d(E.slice(D),A,H)),A,H)}var G=A.length+1,F=A.length-1,B;var C=j(E.slice(F),H).slice(G);var z=E.slice(0,G);var w=j(C,A).slice(0,G);var v=t(z,w);if(v.length==0){z[G]=1;v=t(z,w)}for(var y=0;;y++){B=t(v,A);if(B.length==0){break}v=B;if(y>=3){return d(v,A,H)}}return v}function i(v,C,A){var w=[1],B,D,E=v.concat();var z=A.length*2;var F=new Array(z+1);F[z--]=1;for(;z>=0;z--){F[z]=0}F=new f(F,A).q;for(z=0;z<C.length;z++){for(D=1,B=0;B<o;B++,D<<=1){if(C[z]&D){w=d(j(w,E),A,F)}E=d(j(E,E),A,F)}}return w}function b(w,x,v){return i(w,x,v)}function s(v,C,B,A,w){var z=i(l(v,B),l(C,t(B,[1])),B);var y=i(l(v,A),l(C,t(A,[1])),A);var x=t(y,z);if(x.length==0){x=t(z,y);x=l(j(x,w),A);x=t(A,x)}else{x=l(j(x,w),A)}return g(j(x,B),z)}function r(E){var w=1,v=[0],z=0,C=256;var B,y=E.length;if(y<2){alert("string too short, not a MPI");return 0}var A=(y-2)*8;var D=E.charCodeAt(0)*256+E.charCodeAt(1);if(D>A||D<A-8){alert("not a MPI, bits="+D+",len="+A);return 0}for(var x=0;x<A;x++){if((C<<=1)>255){C=1;B=E.charCodeAt(--y)}if(w>a){w=1;v[++z]=0}if(B&C){v[z]|=w}w<<=1}return v}function e(C){var x=1,B=0,v=[0],w=1,A=0;var D=C.length*o;var y,z="";for(y=0;y<D;y++){if(C[B]&x){v[A]|=w}if((w<<=1)>255){w=1;v[++A]=0}if((x<<=1)>a){x=1;B++}}while(A&&v[A]==0){A--}x=256;for(D=8;D>0;D--){if(v[A]&(x>>=1)){break}}D+=A*8;z+=String.fromCharCode(D/256)+String.fromCharCode(D%256);if(D){for(y=A;y>=0;y--){z+=String.fromCharCode(v[y])}}return z}return{b2mpi:e,encrypt:b,decrypt:s}})();