function encrypt(e,u){var a="",d="";var g=e.length;var h="";var b,v,s,f,f,l;if(u!=null&&u!=""){b=getkeybytes(u);f=b.length}if(a!=null&&a!=""){v=getkeybytes(a);f=v.length}if(d!=null&&d!=""){s=getkeybytes(d);l=s.length}if(g>0){if(g<4){var c=strtobt(e);var e;if(u!=null&&u!=""&&a!=null&&a!=""&&d!=null&&d!=""){var a;var q,p,o;a=c;for(q=0;q0){var b=e.substring(t*4+0,g);var d=strtobt(b);var e;if(u!=null&&u!=""&&a!=null&&a!=""&&d!=null&&d!=""){var a;var q,p,o;a=d;for(q=0;q=0;p--){w=dec(w,q[p])}for(o=d-1;o>=0;o--){w=dec(w,v[o])}for(l=e-1;l>=0;l--){w=dec(w,b[l])}r=w}else{if(t!=null&&t!=""&&a!=null&&a!=""){var w;var p,o,l;w=c;for(p=d-1;p>=0;p--){w=dec(w,v[p])}for(o=e-1;o>=0;o--){w=dec(w,b[o])}r=w}else{if(t!=null&&t!=""){var w;var p,o,l;w=c;for(p=e-1;p>=0;p--){w=dec(w,b[p])}r=w}}}f+=bytetostring(r)}return f}function getkeybytes(d){var a=new array();var c=d.length;var e=parseint(c/4);var f=c%4;var b=0;for(b=0;b0){a[b]=strtobt(d.substring(b*4+0,c))}return a}function strtobt(l){var a=l.length;var o=new array(64);if(a<4){var g=0,f=0,c=0,b=0;for(g=0;gf;d--){h*=2}o[16*g+f]=parseint(e/h)%2}}for(c=a;c<4;c++){var e=0;for(b=0;b<16;b++){var h=1,d=0;for(d=15;d>b;d--){h*=2}o[16*c+b]=parseint(e/h)%2}}}else{for(g=0;g<4;g++){var e=l.charcodeat(g);for(f=0;f<16;f++){var h=1;for(d=15;d>f;d--){h*=2}o[16*g+f]=parseint(e/h)%2}}}return o}function bt4tohex(b){var a; switch(b){case"0000":a="0";break;case"0001":a="1";break;case"0010":a="2";break;case"0011":a="3";break;case"0100":a="4";break;case"0101":a="5";break;case"0110":a="6";break;case"0111":a="7";break;case"1000":a="8";break;case"1001":a="9";break;case"1010":a="a";break;case"1011":a="b";break;case"1100":a="c";break;case"1101":a="d";break;case"1110":a="e";break;case"1111":a="f";break}return a}function hextobt4(a){var b;switch(a){case"0":b="0000";break;case"1":b="0001";break;case"2":b="0010";break;case"3":b="0011"; break;case"4":b="0100";break;case"5":b="0101";break;case"6":b="0110";break;case"7":b="0111";break;case"8":b="1000";break;case"9":b="1001";break;case"a":b="1010";break;case"b":b="1011";break;case"c":b="1100";break;case"d":b="1101";break;case"e":b="1110";break;case"f":b="1111";break}return b}function bytetostring(d){var c="";for(i=0;i<4;i++){var b=0;for(j=0;j<16;j++){var a=1;for(m=15;m>j;m--){a*=2}b+=d[16*i+j]*a}if(b!=0){c+=string.fromcharcode(b)}}return c}function bt64tohex(c){var b="";for(i=0;i<16; i++){var a="";for(j=0;j<4;j++){a+=c[i*4+j]}b+=bt4tohex(a)}return b}function hextobt64(a){var b="";for(i=0;i<16;i++){b+=hextobt4(a.substring(i,i+1))}return b}function enc(b,q){var t=generatekeys(q);var p=initpermute(b);var c=new array(32);var s=new array(32);var g=new array(32);var o=0,l=0,h=0,f=0,e=0;for(h=0;h<32;h++){c[h]=p[h];s[h]=p[32+h]}for(o=0;o<16;o++){for(l=0;l<32;l++){g[l]=c[l];c[l]=s[l]}var r=new array(48);for(f=0;f<48;f++){r[f]=t[o][f]}var a=xor(ppermute(sboxpermute(xor(expandpermute(s),r))),g); for(e=0;e<32;e++){s[e]=a[e]}}var d=new array(64);for(o=0;o<32;o++){d[o]=s[o];d[32+o]=c[o]}return finallypermute(d)}function dec(b,q){var t=generatekeys(q);var p=initpermute(b);var c=new array(32);var s=new array(32);var g=new array(32);var o=0,l=0,h=0,f=0,e=0;for(h=0;h<32;h++){c[h]=p[h];s[h]=p[32+h]}for(o=15;o>=0;o--){for(l=0;l<32;l++){g[l]=c[l];c[l]=s[l]}var r=new array(48);for(f=0;f<48;f++){r[f]=t[o][f]}var a=xor(ppermute(sboxpermute(xor(expandpermute(s),r))),g);for(e=0;e<32;e++){s[e]=a[e]}}var d=new array(64); for(o=0;o<32;o++){d[o]=s[o];d[32+o]=c[o]}return finallypermute(d)}function initpermute(b){var a=new array(64);for(i=0,m=1,n=0;i<4;i++,m+=2,n+=2){for(j=7,k=0;j>=0;j--,k++){a[i*8+k]=b[j*8+m];a[i*8+k+32]=b[j*8+n]}}return a}function expandpermute(a){var b=new array(48);for(i=0;i<8;i++){if(i==0){b[i*6+0]=a[31]}else{b[i*6+0]=a[i*4-1]}b[i*6+1]=a[i*4+0];b[i*6+2]=a[i*4+1];b[i*6+3]=a[i*4+2];b[i*6+4]=a[i*4+3];if(i==7){b[i*6+5]=a[0]}else{b[i*6+5]=a[i*4+4]}}return b}function xor(c,b){var a=new array(c.length); for(i=0;i