diff --git a/bun.lockb b/bun.lockb index 5f6b70f..da4da9e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/dist/index.js b/dist/index.js index 47a4d50..0de94ec 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -class H{keystream;encryptedText;plaintext;nonce;constructor(){this.keystream=[],this.encryptedText=[],this.plaintext=[],this.nonce=[]}rotateleft=(m,E)=>{return m<>>32-E};le32=(m,E,I,f)=>{return(m^E<<8^I<<16^f<<24)>>>0};int2(m){let E=[];for(let I=0;I>>=0,m[I]>>>=0,m[f]>>>=0,m[l]>>>=0}Inner_Block(m){this.Qround(m,0,4,8,12),this.Qround(m,1,5,9,13),this.Qround(m,2,6,10,14),this.Qround(m,3,7,11,15),this.Qround(m,0,5,10,15),this.Qround(m,1,6,11,12),this.Qround(m,2,7,8,13),this.Qround(m,3,4,9,14)}Chacha20_BlockFunction(m,E,I){let f=[];f[0]=1634760805,f[1]=857760878,f[2]=2036477234,f[3]=1797285236,f[4]=this.le32(m[0],m[1],m[2],m[3]),f[5]=this.le32(m[4],m[5],m[6],m[7]),f[6]=this.le32(m[8],9,m[10],m[11]),f[7]=this.le32(m[12],m[13],m[14],m[15]),f[8]=this.le32(m[16],m[17],18,m[19]),f[9]=this.le32(m[20],m[21],22,m[23]),f[10]=this.le32(m[24],m[25],m[26],m[27]),f[11]=this.le32(m[28],m[29],m[30],m[31]),f[12]=I,f[13]=this.le32(E[0],E[1],E[2],E[3]),f[14]=this.le32(E[4],E[5],E[6],E[7]),f[15]=this.le32(E[8],E[9],E[10],E[11]);let l=new Uint32Array(f.slice());for(let L=1;L<=10;L++)this.Inner_Block(l);let v=[];for(let L=0,u=0;L<16;L++)f[L]+=l[L],v[u++]=f[L]&255,v[u++]=f[L]>>>8&255,v[u++]=f[L]>>>16&255,v[u++]=f[L]>>>24&255;return v}HChacha20_BlockFunction(m,E){let I=[];I[0]=1634760805,I[1]=857760878,I[2]=2036477234,I[3]=1797285236,I[4]=this.le32(m[0],m[1],m[2],m[3]),I[5]=this.le32(m[4],m[5],m[6],m[7]),I[6]=this.le32(m[8],9,m[10],m[11]),I[7]=this.le32(m[12],m[13],m[14],m[15]),I[8]=this.le32(m[16],m[17],18,m[19]),I[9]=this.le32(m[20],m[21],22,m[23]),I[10]=this.le32(m[24],m[25],m[26],m[27]),I[11]=this.le32(m[28],m[29],m[30],m[31]),I[12]=this.le32(E[0],E[1],E[2],E[3]),I[13]=this.le32(E[4],E[5],E[6],E[7]),I[14]=this.le32(E[8],E[9],E[10],E[11]),I[15]=this.le32(E[12],E[13],E[14],E[15]);let f=new Uint32Array(I.slice());for(let P=1;P<=10;P++)this.Inner_Block(f);let l=f.slice(0,4),v=f.slice(12,16),L=new Uint32Array(l.length+v.length);L.set(l),L.set(v,l.length);let u=[];for(let P=0,M=0;P<8;P++)u[M++]=L[P]&255,u[M++]=L[P]>>>8&255,u[M++]=L[P]>>>16&255,u[M++]=L[P]>>>24&255;return u}chacha20_encrypt(m,E,I,f){let l=[];l.push(...this.Chacha20_BlockFunction(m,I,E));let v=0;for(let u=0;u{let m=V.value,E=j.value;Z.value=H.encrypt(m,E)});document.getElementById("btn-decrypt")?.addEventListener("click",()=>{let m=V.value,E=j.value;Z.value=H.decrypt(m,E)});document.getElementById("btn-start")?.addEventListener("click",()=>{let m=parseInt(q.value,10);if(m<1)m=1;if(m>1e5)m=1e5;const E=document.getElementById("perf");if(!E)return;let I=[],f=[],l=[],v="lTmnm8G6X1ESDuVf1xnf2t1F4XpUZzZYfodPQQbprsx40k3n9d",L=Date.now();E.innerText="1. Performance test has started.\n";let u=Date.now();for(let P=0;P{return m<>>32-E};le32=(m,E,I,f)=>{return(m^E<<8^I<<16^f<<24)>>>0};int2(m){let E=[];for(let I=0;I>>=0,m[I]>>>=0,m[f]>>>=0,m[l]>>>=0}Inner_Block(m){this.Qround(m,0,4,8,12),this.Qround(m,1,5,9,13),this.Qround(m,2,6,10,14),this.Qround(m,3,7,11,15),this.Qround(m,0,5,10,15),this.Qround(m,1,6,11,12),this.Qround(m,2,7,8,13),this.Qround(m,3,4,9,14)}Chacha20_BlockFunction(m,E,I){let f=[];f[0]=1634760805,f[1]=857760878,f[2]=2036477234,f[3]=1797285236,f[4]=this.le32(m[0],m[1],m[2],m[3]),f[5]=this.le32(m[4],m[5],m[6],m[7]),f[6]=this.le32(m[8],9,m[10],m[11]),f[7]=this.le32(m[12],m[13],m[14],m[15]),f[8]=this.le32(m[16],m[17],18,m[19]),f[9]=this.le32(m[20],m[21],22,m[23]),f[10]=this.le32(m[24],m[25],m[26],m[27]),f[11]=this.le32(m[28],m[29],m[30],m[31]),f[12]=I,f[13]=this.le32(E[0],E[1],E[2],E[3]),f[14]=this.le32(E[4],E[5],E[6],E[7]),f[15]=this.le32(E[8],E[9],E[10],E[11]);let l=new Uint32Array(f.slice());for(let L=1;L<=10;L++)this.Inner_Block(l);let v=[];for(let L=0,u=0;L<16;L++)f[L]+=l[L],v[u++]=f[L]&255,v[u++]=f[L]>>>8&255,v[u++]=f[L]>>>16&255,v[u++]=f[L]>>>24&255;return v}HChacha20_BlockFunction(m,E){let I=[];I[0]=1634760805,I[1]=857760878,I[2]=2036477234,I[3]=1797285236,I[4]=this.le32(m[0],m[1],m[2],m[3]),I[5]=this.le32(m[4],m[5],m[6],m[7]),I[6]=this.le32(m[8],9,m[10],m[11]),I[7]=this.le32(m[12],m[13],m[14],m[15]),I[8]=this.le32(m[16],m[17],18,m[19]),I[9]=this.le32(m[20],m[21],22,m[23]),I[10]=this.le32(m[24],m[25],m[26],m[27]),I[11]=this.le32(m[28],m[29],m[30],m[31]),I[12]=this.le32(E[0],E[1],E[2],E[3]),I[13]=this.le32(E[4],E[5],E[6],E[7]),I[14]=this.le32(E[8],E[9],E[10],E[11]),I[15]=this.le32(E[12],E[13],E[14],E[15]);let f=new Uint32Array(I.slice());for(let P=1;P<=10;P++)this.Inner_Block(f);let l=f.slice(0,4),v=f.slice(12,16),L=new Uint32Array(l.length+v.length);L.set(l),L.set(v,l.length);let u=[];for(let P=0,M=0;P<8;P++)u[M++]=L[P]&255,u[M++]=L[P]>>>8&255,u[M++]=L[P]>>>16&255,u[M++]=L[P]>>>24&255;return u}chacha20_encrypt(m,E,I,f){let l=[];l.push(...this.Chacha20_BlockFunction(m,I,E));let v=0;for(let u=0;u{let m=V.value,E=j.value;Z.value=H.encrypt(m,E)});document.getElementById("btn-decrypt")?.addEventListener("click",()=>{let m=V.value,E=j.value;Z.value=H.decrypt(m,E)});document.getElementById("btn-start")?.addEventListener("click",()=>{let m=parseInt(q.value,10);if(m<1)m=1;if(m>1e5)m=1e5;const E=document.getElementById("perf");if(!E)return;let I=[],f=[],l=[],v="lTmnm8G6X1ESDuVf1xnf2t1F4XpUZzZYfodPQQbprsx40k3n9d",L=Date.now();E.innerText="1. Performance test has started.\n";let u=Date.now();for(let P=0;P