(function(a){a.jCryption=function(c,b){var d=this;d.$el=a(c);d.el=c;d.$el.data("jCryption",d);d.init=function(){d.options=a.extend({},a.jCryption.defaultOptions,b);$encryptedElement=a("<input />",{type:"hidden",name:d.options.postVariable});(!1!==d.options.submitElement?d.options.submitElement:d.$el.find(":input:submit")).bind(d.options.submitEvent,function(){a(this).attr("disabled",!0);d.options.beforeEncryption()&&a.jCryption.getKeys(d.options.getKeysURL,function(b){a.jCryption.encrypt(d.$el.serialize(),
b,function(b){$encryptedElement.val(b);a(d.$el).find(":input").attr("disabled",!0).end().append($encryptedElement).submit()})});return!1})};d.init()};a.jCryption.getKeys=function(c,b){data=c;keys=new function(a,b,c){setMaxDigits(parseInt(c,10));this.e=biFromHex(a);this.m=biFromHex(b);this.chunkSize=2*biHighIndex(this.m);this.radix=16;this.barrett=new BarrettMu(this.m)}(data.e,data.n,data.maxdigits);a.isFunction(b)&&b.call(this,keys)};a.jCryption.encrypt=function(c,b,d){for(var e=0,f=0;f<c.length;f++)e+=
c.charCodeAt(f);c=""+("0123456789abcdef".charAt((e&240)>>4)+"0123456789abcdef".charAt(e&15))+c;e=[];for(f=0;f<c.length;)e[f]=c.charCodeAt(f),f++;for(;0!==e.length%b.chunkSize;)e[f++]=0;(function(c){function e(){m=new BigInt;l=0;for(var k=f;k<f+b.chunkSize;++l)m.digits[l]=c[k++],m.digits[l]+=c[k++]<<8;k=b.barrett.powMod(m,b.e);k=16==b.radix?biToHex(k):biToString(k,b.radix);n+=k+" ";f+=b.chunkSize;if(f<c.length)setTimeout(e,1);else if(k=n.substring(0,n.length-1),a.isFunction(d))d(k);else return k}var f=
0,l,m,n="";setTimeout(e,1)})(e)};a.jCryption.defaultOptions={submitElement:!1,submitEvent:"click",getKeysURL:"main.php?generateKeypair=true",beforeEncryption:function(){return!0},postVariable:"mywebsql_auth"};a.fn.jCryption=function(c){return this.each(function(){new a.jCryption(this,c)})}})(jQuery);
var biRadixBase=2,biRadixBits=16,bitsPerDigit=biRadixBits,biRadix=65536,biHalfRadix=biRadix>>>1,biRadixSquared=biRadix*biRadix,maxDigitVal=biRadix-1,maxInteger=9999999999999998,maxDigits,ZERO_ARRAY,bigZero,bigOne,dpl10=15,highBitMasks=[0,32768,49152,57344,61440,63488,64512,65024,65280,65408,65472,65504,65520,65528,65532,65534,65535],hexatrigesimalToChar="0123456789abcdefghijklmnopqrstuvwxyz".split(""),hexToChar="0123456789abcdef".split(""),lowBitMasks=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,
8191,16383,32767,65535];function setMaxDigits(a){maxDigits=a;ZERO_ARRAY=Array(maxDigits);for(a=0;a<ZERO_ARRAY.length;a++)ZERO_ARRAY[a]=0;bigZero=new BigInt;bigOne=new BigInt;bigOne.digits[0]=1}function BigInt(a){this.digits="boolean"==typeof a&&1==a?null:ZERO_ARRAY.slice(0);this.isNeg=!1}
function biFromDecimal(a){for(var c="-"==a.charAt(0),b=c?1:0,d;b<a.length&&"0"==a.charAt(b);)++b;if(b==a.length)d=new BigInt;else{var e=(a.length-b)%dpl10;0==e&&(e=dpl10);d=biFromNumber(Number(a.substr(b,e)));for(b+=e;b<a.length;)d=biAdd(biMultiply(d,biFromNumber(1E15)),biFromNumber(Number(a.substr(b,dpl10)))),b+=dpl10;d.isNeg=c}return d}function biCopy(a){var c=new BigInt(!0);c.digits=a.digits.slice(0);c.isNeg=a.isNeg;return c}
function biFromNumber(a){var c=new BigInt;c.isNeg=0>a;a=Math.abs(a);for(var b=0;0<a;)c.digits[b++]=a&maxDigitVal,a>>=biRadixBits;return c}function reverseStr(a){for(var c="",b=a.length-1;-1<b;--b)c+=a.charAt(b);return c}function biToString(a,c){var b=new BigInt;b.digits[0]=c;for(var d=biDivideModulo(a,b),e=hexatrigesimalToChar[d[1].digits[0]];1==biCompare(d[0],bigZero);)d=biDivideModulo(d[0],b),digit=d[1].digits[0],e+=hexatrigesimalToChar[d[1].digits[0]];return(a.isNeg?"-":"")+reverseStr(e)}
function biToDecimal(a){var c=new BigInt;c.digits[0]=10;for(var b=biDivideModulo(a,c),d=String(b[1].digits[0]);1==biCompare(b[0],bigZero);)b=biDivideModulo(b[0],c),d+=String(b[1].digits[0]);return(a.isNeg?"-":"")+reverseStr(d)}function digitToHex(a){var c="";for(i=0;4>i;++i)c+=hexToChar[a&15],a>>>=4;return reverseStr(c)}function biToHex(a){var c="";biHighIndex(a);for(var b=biHighIndex(a);-1<b;--b)c+=digitToHex(a.digits[b]);return c}
function charToHex(a){return 48<=a&&57>=a?a-48:65<=a&&90>=a?10+a-65:97<=a&&122>=a?10+a-97:0}function hexToDigit(a){for(var c=0,b=Math.min(a.length,4),d=0;d<b;++d)c<<=4,c|=charToHex(a.charCodeAt(d));return c}function biFromHex(a){for(var c=new BigInt,b=a.length,d=0;0<b;b-=4,++d)c.digits[d]=hexToDigit(a.substr(Math.max(b-4,0),Math.min(b,4)));return c}
function biFromString(a,c){var b="-"==a.charAt(0),d=b?1:0,e=new BigInt,f=new BigInt;f.digits[0]=1;for(var g=a.length-1;g>=d;g--)var h=a.charCodeAt(g),h=charToHex(h),h=biMultiplyDigit(f,h),e=biAdd(e,h),f=biMultiplyDigit(f,c);e.isNeg=b;return e}function biDump(a){return(a.isNeg?"-":"")+a.digits.join(" ")}
function biAdd(a,c){var b;if(a.isNeg!=c.isNeg)c.isNeg=!c.isNeg,b=biSubtract(a,c),c.isNeg=!c.isNeg;else{b=new BigInt;for(var d=0,e=0;e<a.digits.length;++e)d=a.digits[e]+c.digits[e]+d,b.digits[e]=d&65535,d=Number(d>=biRadix);b.isNeg=a.isNeg}return b}
function biSubtract(a,c){var b;if(a.isNeg!=c.isNeg)c.isNeg=!c.isNeg,b=biAdd(a,c),c.isNeg=!c.isNeg;else{b=new BigInt;for(var d,e=d=0;e<a.digits.length;++e)d=a.digits[e]-c.digits[e]+d,b.digits[e]=d&65535,0>b.digits[e]&&(b.digits[e]+=biRadix),d=0-Number(0>d);if(-1==d){for(e=d=0;e<a.digits.length;++e)d=0-b.digits[e]+d,b.digits[e]=d&65535,0>b.digits[e]&&(b.digits[e]+=biRadix),d=0-Number(0>d);b.isNeg=!a.isNeg}else b.isNeg=a.isNeg}return b}
function biHighIndex(a){for(var c=a.digits.length-1;0<c&&0==a.digits[c];)--c;return c}function biNumBits(a){var c=biHighIndex(a);a=a.digits[c];var c=(c+1)*bitsPerDigit,b;for(b=c;b>c-bitsPerDigit&&0==(a&32768);--b)a<<=1;return b}function biMultiply(a,c){for(var b=new BigInt,d,e=biHighIndex(a),f=biHighIndex(c),g,h=0;h<=f;++h){d=0;g=h;for(j=0;j<=e;++j,++g)d=b.digits[g]+a.digits[j]*c.digits[h]+d,b.digits[g]=d&maxDigitVal,d>>>=biRadixBits;b.digits[h+e+1]=d}b.isNeg=a.isNeg!=c.isNeg;return b}
function biMultiplyDigit(a,c){var b,d,e=new BigInt;b=biHighIndex(a);for(var f=d=0;f<=b;++f)d=e.digits[f]+a.digits[f]*c+d,e.digits[f]=d&maxDigitVal,d>>>=biRadixBits;e.digits[1+b]=d;return e}function arrayCopy(a,c,b,d,e){for(e=Math.min(c+e,a.length);c<e;++c,++d)b[d]=a[c]}
function biShiftLeft(a,c){var b=Math.floor(c/bitsPerDigit),d=new BigInt;arrayCopy(a.digits,0,d.digits,b,d.digits.length-b);for(var b=c%bitsPerDigit,e=bitsPerDigit-b,f=d.digits.length-1,g=f-1;0<f;--f,--g)d.digits[f]=d.digits[f]<<b&maxDigitVal|(d.digits[g]&highBitMasks[b])>>>e;d.digits[0]=d.digits[f]<<b&maxDigitVal;d.isNeg=a.isNeg;return d}
function biShiftRight(a,c){var b=Math.floor(c/bitsPerDigit),d=new BigInt;arrayCopy(a.digits,b,d.digits,0,a.digits.length-b);for(var b=c%bitsPerDigit,e=bitsPerDigit-b,f=0,g=f+1;f<d.digits.length-1;++f,++g)d.digits[f]=d.digits[f]>>>b|(d.digits[g]&lowBitMasks[b])<<e;d.digits[d.digits.length-1]>>>=b;d.isNeg=a.isNeg;return d}function biMultiplyByRadixPower(a,c){var b=new BigInt;arrayCopy(a.digits,0,b.digits,c,b.digits.length-c);return b}
function biDivideByRadixPower(a,c){var b=new BigInt;arrayCopy(a.digits,c,b.digits,0,b.digits.length-c);return b}function biModuloByRadixPower(a,c){var b=new BigInt;arrayCopy(a.digits,0,b.digits,0,c);return b}function biCompare(a,c){if(a.isNeg!=c.isNeg)return 1-2*Number(a.isNeg);for(var b=a.digits.length-1;0<=b;--b)if(a.digits[b]!=c.digits[b])return a.isNeg?1-2*Number(a.digits[b]>c.digits[b]):1-2*Number(a.digits[b]<c.digits[b]);return 0}
function biDivideModulo(a,c){var b=biNumBits(a),d=biNumBits(c),e=c.isNeg,f,g;if(b<d)return a.isNeg?(f=biCopy(bigOne),f.isNeg=!c.isNeg,a.isNeg=!1,c.isNeg=!1,g=biSubtract(c,a),a.isNeg=!0,c.isNeg=e):(f=new BigInt,g=biCopy(a)),[f,g];f=new BigInt;g=a;for(var h=Math.ceil(d/bitsPerDigit)-1,p=0;c.digits[h]<biHalfRadix;)c=biShiftLeft(c,1),++p,++d,h=Math.ceil(d/bitsPerDigit)-1;g=biShiftLeft(g,p);b=Math.ceil((b+p)/bitsPerDigit)-1;for(d=biMultiplyByRadixPower(c,b-h);-1!=biCompare(g,d);)++f.digits[b-h],g=biSubtract(g,
d);for(;b>h;--b){var d=b>=g.digits.length?0:g.digits[b],l=b-1>=g.digits.length?0:g.digits[b-1],m=b-2>=g.digits.length?0:g.digits[b-2],n=h>=c.digits.length?0:c.digits[h],k=h-1>=c.digits.length?0:c.digits[h-1];f.digits[b-h-1]=d==n?maxDigitVal:Math.floor((d*biRadix+l)/n);for(var q=f.digits[b-h-1]*(n*biRadix+k),r=d*biRadixSquared+(l*biRadix+m);q>r;)--f.digits[b-h-1],q=f.digits[b-h-1]*(n*biRadix|k),r=d*biRadix*biRadix+(l*biRadix+m);d=biMultiplyByRadixPower(c,b-h-1);g=biSubtract(g,biMultiplyDigit(d,f.digits[b-
h-1]));g.isNeg&&(g=biAdd(g,d),--f.digits[b-h-1])}g=biShiftRight(g,p);f.isNeg=a.isNeg!=e;a.isNeg&&(f=e?biAdd(f,bigOne):biSubtract(f,bigOne),c=biShiftRight(c,p),g=biSubtract(c,g));0==g.digits[0]&&0==biHighIndex(g)&&(g.isNeg=!1);return[f,g]}function biDivide(a,c){return biDivideModulo(a,c)[0]}function biModulo(a,c){return biDivideModulo(a,c)[1]}function biMultiplyMod(a,c,b){return biModulo(biMultiply(a,c),b)}
function biPow(a,c){for(var b=bigOne,d=a;;){0!=(c&1)&&(b=biMultiply(b,d));c>>=1;if(0==c)break;d=biMultiply(d,d)}return b}function biPowMod(a,c,b){for(var d=bigOne;;){0!=(c.digits[0]&1)&&(d=biMultiplyMod(d,a,b));c=biShiftRight(c,1);if(0==c.digits[0]&&0==biHighIndex(c))break;a=biMultiplyMod(a,a,b)}return d}
function BarrettMu(a){this.modulus=biCopy(a);this.k=biHighIndex(this.modulus)+1;a=new BigInt;a.digits[2*this.k]=1;this.mu=biDivide(a,this.modulus);this.bkplus1=new BigInt;this.bkplus1.digits[this.k+1]=1;this.modulo=BarrettMu_modulo;this.multiplyMod=BarrettMu_multiplyMod;this.powMod=BarrettMu_powMod}
function BarrettMu_modulo(a){var c=biDivideByRadixPower(a,this.k-1),c=biMultiply(c,this.mu),c=biDivideByRadixPower(c,this.k+1);a=biModuloByRadixPower(a,this.k+1);c=biMultiply(c,this.modulus);c=biModuloByRadixPower(c,this.k+1);a=biSubtract(a,c);a.isNeg&&(a=biAdd(a,this.bkplus1));for(c=0<=biCompare(a,this.modulus);c;)a=biSubtract(a,this.modulus),c=0<=biCompare(a,this.modulus);return a}function BarrettMu_multiplyMod(a,c){var b=biMultiply(a,c);return this.modulo(b)}
function BarrettMu_powMod(a,c){var b=new BigInt;for(b.digits[0]=1;;){0!=(c.digits[0]&1)&&(b=this.multiplyMod(b,a));c=biShiftRight(c,1);if(0==c.digits[0]&&0==biHighIndex(c))break;a=this.multiplyMod(a,a)}return b};
