Files
inzerosight/dist/web/assets/index-wRI3Wnct.js

5 lines
12 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))b(d);new MutationObserver(d=>{for(const p of d)if(p.type==="childList")for(const s of p.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&b(s)}).observe(document,{childList:!0,subtree:!0});function a(d){const p={};return d.integrity&&(p.integrity=d.integrity),d.referrerPolicy&&(p.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?p.credentials="include":d.crossOrigin==="anonymous"?p.credentials="omit":p.credentials="same-origin",p}function b(d){if(d.ep)return;d.ep=!0;const p=a(d);fetch(d.href,p)}})();const A={3:{unifier:"­",0:"",1:"",2:""},6:{unifier:"",0:"",1:"",2:"­",3:"",4:"",5:""},8:{unifier:"",0:"",1:"",2:"­",3:"",4:"",5:"",6:"",7:"\uFEFF"},encodeString:(i,n=3)=>Array.from(i,a=>a.codePointAt(0).toString(n).split("").map(b=>A[n][b]).join("")).join(A[n].unifier),encodeNumberArray:(i,n=3)=>i.map(a=>a.toString(n).split("").map(b=>A[n][b]).join("")).join(A[n].unifier),decodeToString:(i,n=3)=>i.split(A[n].unifier).map(a=>String.fromCodePoint(parseInt(Array.from(a).map(b=>Object.keys(A[n]).find(d=>A[n][d]===b)).join(""),n))).join(""),decodeToNumberArray:(i,n=3)=>i.split(A[n].unifier).map(a=>parseInt(Array.from(a).map(b=>Object.keys(A[n]).find(d=>A[n][d]===b)).join(""),n))};function ne(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var D,j;function re(){if(j)return D;j=1;function i(n={}){const a=n.bits||16,b=n.rounds||22,d=n.rightRotations||7,p=n.leftRotations||2,s=2**a,o=s-1,l=(c,t)=>c>>t|c<<a-t&o,m=(c,t)=>c<<t&o|c>>a-t,y=(c,t,e)=>(c=l(c,d),c=c+t&o,c^=e,t=m(t,p),t^=c,[c,t]),I=(c,t,e)=>(t^=c,t=l(t,p),c^=e,c=c-t&o,c=m(c,d),[c,t]);function w(c,t){let e=c[0],u=c[1],r=t[0],g=t.slice(1);[u,e]=y(u,e,r);for(let h=0;h<b-1;h++){const k=h%g.length;[g[k],r]=y(g[k],r,h),[u,e]=y(u,e,r)}return[e,u]}function E(c,t){let e=c[0],u=c[1],r=t[0],g=t.slice(1);for(let h=0;h<b-1;h++){const k=h%g.length;[g[k],r]=y(g[k],r,h)}for(let h=0;h<b;h++){const k=(b-2-h)%g.length;[u,e]=I(u,e,r),[g[k],r]=I(g[k],r,b-2-h)}return[e,u]}function f(c){return(t,e)=>{const u=c([t/s|0,t&o],e);return u[0]*s+u[1]}}return{encrypt:f(w),decrypt:f(E),encryptRaw:w,decryptRaw:E}}return D=i,D}var oe=re();const K=ne(oe);var R,_;function q(){if(_)return R;_=1;const i="Input must be an string, Buffer or Uint8Array";function n(s){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=new TextEncoder().encode(s);else throw new Error(i);return o}function a(s){return Array.prototype.map.call(s,function(o){return(o<16?"0":"")+o.toString(16)}).join("")}function b(s){return(4294967296+s).toString(16).substring(1)}function d(s,o,l){let m=`
`+s+" = ";for(let y=0;y<o.length;y+=2){if(l===32)m+=b(o[y]).toUpperCase(),m+=" ",m+=b(o[y+1]).toUpperCase();else if(l===64)m+=b(o[y+1]).toUpperCase(),m+=b(o[y]).toUpperCase();else throw new Error("Invalid size "+l);y%6===4?m+=`
`+new Array(s.length+4).join(" "):y<o.length-2&&(m+=" ")}console.log(m)}function p(s,o,l){let m=new Date().getTime();const y=new Uint8Array(o);for(let w=0;w<o;w++)y[w]=w%256;const I=new Date().getTime();console.log("Generated random input in "+(I-m)+"ms"),m=I;for(let w=0;w<l;w++){const E=s(y),f=new Date().getTime(),c=f-m;m=f,console.log("Hashed in "+c+"ms: "+E.substring(0,20)+"..."),console.log(Math.round(o/(1<<20)/(c/1e3)*100)/100+" MB PER SECOND")}}return R={normalizeInput:n,toHex:a,debugPrint:d,testSpeed:p},R}var T,N;function ie(){if(N)return T;N=1;const i=q();function n(e,u,r){const g=e[u]+e[r];let h=e[u+1]+e[r+1];g>=4294967296&&h++,e[u]=g,e[u+1]=h}function a(e,u,r,g){let h=e[u]+r;r<0&&(h+=4294967296);let k=e[u+1]+g;h>=4294967296&&k++,e[u]=h,e[u+1]=k}function b(e,u){return e[u]^e[u+1]<<8^e[u+2]<<16^e[u+3]<<24}function d(e,u,r,g,h,k){const J=m[h],Q=m[h+1],ee=m[k],te=m[k+1];n(l,e,u),a(l,e,J,Q);let S=l[g]^l[e],B=l[g+1]^l[e+1];l[g]=B,l[g+1]=S,n(l,r,g),S=l[u]^l[r],B=l[u+1]^l[r+1],l[u]=S>>>24^B<<8,l[u+1]=B>>>24^S<<8,n(l,e,u),a(l,e,ee,te),S=l[g]^l[e],B=l[g+1]^l[e+1],l[g]=S>>>16^B<<16,l[g+1]=B>>>16^S<<16,n(l,r,g),S=l[u]^l[r],B=l[u+1]^l[r+1],l[u]=B>>>31^S<<1,l[u+1]=S>>>31^B<<1}const p=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],o=new Uint8Array(s.map(function(e){return e*2})),l=new Uint32Array(32),m=new Uint32Array(32);function y(e,u){let r=0;for(r=0;r<16;r++)l[r]=e.h[r],l[r+16]=p[r];for(l[24]=l[24]^e.t,l[25]=l[25]^e.t/4294967296,u&&(l[28]=~l[28],l[29]=~l[29]),r=0;r<32;r++)m[r]=b(e.b,4*r);for(r=0;r<12;r++)d(0,8,16,24,o[r*16+0],o[r*16+1]),d(2,10,18,26,o[r*16+2],o[r*16+3]),d(4,12,20,28,o[r*16+4],o[r*16+5]),d(6,14,22,30,o[r*16+6],o[r*16+7]),d(0,10,20,30,o[r*16+8],o[r*16+9]),d(2,12,22,24,o[r*16+10],o[r*16+11]),d(4,14,16,26,o[r*16+12],o[r*16+13]),d(6,8,18,28,o[r*16+14],o[r*16+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^l[r]^l[r+16]}const I=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function w(e,u,r,g){if(e===0||e>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(u&&u.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(r&&r.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(g&&g.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const h={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e};I.fill(0),I[0]=e,u&&(I[1]=u.length),I[2]=1,I[3]=1,r&&I.set(r,32),g&&I.set(g,48);for(let k=0;k<16;k++)h.h[k]=p[k]^b(I,k*4);return u&&(E(h,u),h.c=128),h}function E(e,u){for(let r=0;r<u.length;r++)e.c===128&&(e.t+=e.c,y(e,!1),e.c=0),e.b[e.c++]=u[r]}function f(e){for(e.t+=e.c;e.c<128;)e.b[e.c++]=0;y(e,!0);const u=new Uint8Array(e.outlen);for(let r=0;r<e.outlen;r++)u[r]=e.h[r>>2]>>8*(r&3);return u}function c(e,u,r,g,h){r=r||64,e=i.normalizeInput(e),g&&(g=i.normalizeInput(g)),h&&(h=i.normalizeInput(h));const k=w(r,u,g,h);return E(k,e),f(k)}function t(e,u,r,g,h){const k=c(e,u,r,g,h);return i.toHex(k)}return T={blake2b:c,blake2bHex:t,blake2bInit:w,blake2bUpdate:E,blake2bFinal:f},T}var O,L;function ce(){if(L)return O;L=1;const i=q();function n(f,c){return f[c]^f[c+1]<<8^f[c+2]<<16^f[c+3]<<24}function a(f,c,t,e,u,r){s[f]=s[f]+s[c]+u,s[e]=b(s[e]^s[f],16),s[t]=s[t]+s[e],s[c]=b(s[c]^s[t],12),s[f]=s[f]+s[c]+r,s[e]=b(s[e]^s[f],8),s[t]=s[t]+s[e],s[c]=b(s[c]^s[t],7)}function b(f,c){return f>>>c^f<<32-c}const d=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),p=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),s=new Uint32Array(16),o=new Uint32Array(16);function l(f,c){let t=0;for(t=0;t<8;t++)s[t]=f.h[t],s[t+8]=d[t];for(s[12]^=f.t,s[13]^=f.t/4294967296,c&&(s[14]=~s[14]),t=0;t<16;t++)o[t]=n(f.b,4*t);for(t=0;t<10;t++)a(0,4,8,12,o[p[t*16+0]],o[p[t*16+1]]),a(1,5,9,13,o[p[t*16+2]],o[p[t*16+3]]),a(2,6,10,14,o[p[t*16+4]],o[p[t*16+5]]),a(3,7,11,15,o[p[t*16+6]],o[p[t*16+7]]),a(0,5,10,15,o[p[t*16+8]],o[p[t*16+9]]),a(1,6,11,12,o[p[t*16+10]],o[p[t*16+11]]),a(2,7,8,13,o[p[t*16+12]],o[p[t*16+13]]),a(3,4,9,14,o[p[t*16+14]],o[p[t*16+15]]);for(t=0;t<8;t++)f.h[t]^=s[t]^s[t+8]}function m(f,c){if(!(f>0&&f<=32))throw new Error("Incorrect output length, should be in [1, 32]");const t=c?c.length:0;if(c&&!(t>0&&t<=32))throw new Error("Incorrect key length, should be in [1, 32]");const e={h:new Uint32Array(d),b:new Uint8Array(64),c:0,t:0,outlen:f};return e.h[0]^=16842752^t<<8^f,t>0&&(y(e,c),e.c=64),e}function y(f,c){for(let t=0;t<c.length;t++)f.c===64&&(f.t+=f.c,l(f,!1),f.c=0),f.b[f.c++]=c[t]}function I(f){for(f.t+=f.c;f.c<64;)f.b[f.c++]=0;l(f,!0);const c=new Uint8Array(f.outlen);for(let t=0;t<f.outlen;t++)c[t]=f.h[t>>2]>>8*(t&3)&255;return c}function w(f,c,t){t=t||32,f=i.normalizeInput(f);const e=m(t,c);return y(e,f),I(e)}function E(f,c,t){const e=w(f,c,t);return i.toHex(e)}return O={blake2s:w,blake2sHex:E,blake2sInit:m,blake2sUpdate:y,blake2sFinal:I},O}var P,v;function se(){if(v)return P;v=1;const i=ie(),n=ce();return P={blake2b:i.blake2b,blake2bHex:i.blake2bHex,blake2bInit:i.blake2bInit,blake2bUpdate:i.blake2bUpdate,blake2bFinal:i.blake2bFinal,blake2s:n.blake2s,blake2sHex:n.blake2sHex,blake2sInit:n.blake2sInit,blake2sUpdate:n.blake2sUpdate,blake2sFinal:n.blake2sFinal},P}var z=se();const $=K({bits:24,rounds:23,rightRotations:8,leftRotations:3});function H(i){const n=z.blake2bHex(i,null,12);return[parseInt(n.slice(0,6),16),parseInt(n.slice(6,12),16),parseInt(n.slice(12,18),16),parseInt(n.slice(18,24),16)]}function le(i,n){const a=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]&16777215,b=Array.from(i,(d,p)=>{const s=a*16777216+(p&16777215),o=$.encrypt(s,n);return(d.codePointAt(0)^o)>>>0});return[a,...b]}function ue(i,n){if(!i||i.length===0)return"";const a=i[0];return i.slice(1).map((d,p)=>{const s=a*16777216+(p&16777215),o=$.encrypt(s,n),l=(d^o)>>>0;try{return String.fromCodePoint(l)}catch{return""}}).join("")}const Y=K();function x(i){const n=z.blake2bHex(i,null,8);return[parseInt(n.slice(0,4),16),parseInt(n.slice(4,8),16),parseInt(n.slice(8,12),16),parseInt(n.slice(12,16),16)]}function ae(i,n){return Array.from(i,a=>Y.encrypt(a.codePointAt(0),n))}function fe(i,n){return i.map(a=>{try{return String.fromCodePoint(Y.decrypt(a,n))}catch{return""}}).join("")}const de="­",C={3:"­",6:"­",8:"­"},V={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"},pe=Object.fromEntries(Object.entries(V).map(([i,n])=>[n,+i]));function be(i,n){let a=C[i];const b=pe[n];if(b){const d=Array.from(b.toString(i).padStart(3,"0"),p=>A[i][p]).join("");a+=A[i].unifier+A[i][0]+d}return a}function ge(i){if(!i.includes(de))return null;const n=Object.keys(C).find(p=>i.includes(C[p]));if(!n)return null;const a=i.indexOf(C[n]),b=i.slice(a+C[n].length),d=A[n].unifier+A[n][0];if(b.startsWith(d)){const s=Array.from(b.slice(d.length,d.length+3)).map(y=>Object.keys(A[n]).find(I=>A[n][I]===y)).join(""),o=V[parseInt(s,n)],l=b.slice(d.length+3),m=C[n].length+d.length+3;return{base:n,cipher:o,payload:l,sigIdx:a,sigLen:m}}return{base:n,cipher:"PLAIN",payload:b,sigIdx:a,sigLen:C[n].length}}const U=document.getElementById("textarea"),M=document.getElementById("encoder"),W=document.getElementById("cipher"),X=document.getElementById("sign"),F=document.getElementById("sigDetect");document.getElementById("encodeButton").addEventListener("click",Z);document.getElementById("decodeButton").addEventListener("click",Z);X.addEventListener("click",i=>i.target.classList.toggle("on"));let G;function Z(i){if(clearTimeout(G),F.className="",U.value===""){U.value="The text box is empty.";return}const n=i.target.id==="encodeButton"?"NO":"YES";let a=he(),b=M.value.split("-")[1],d=U.value;if(n==="YES"){const o=ge(d);if(o){if(o.base!==b||o.cipher&&o.cipher!==a){const l=o.cipher&&o.cipher!=="PLAIN"?` (${o.cipher})`:"";F.textContent=`ZWUS-${o.base}${l} signature detected`,F.className="show",G=setTimeout(()=>F.className="",2e3)}b=o.base,M.value="ZWUS-"+b,o.cipher&&(a=o.cipher,W.value=a),d=d.slice(0,o.sigIdx)+o.payload}}const p=a!=="PLAIN",s=p&&prompt("enter password.");if(!(p&&!s)){try{let o=me[n][a](d,b,s);n==="NO"&&X.classList.contains("on")&&(o=be(b,a)+o),U.value=o}catch(o){console.log(o)}n==="NO"&&(U.select(),document.execCommand("copy"),U.value=`Copied to your clipboard.
A copy has been placed between these brackets [`+U.value+"]")}}function he(){return W.value}const me={NO:{PLAIN:(i,n)=>A.encodeString(i,n),SPECK48_96CTR:(i,n,a)=>A.encodeNumberArray(le(i,H(a)),n),"SPECK32_64ECB (insecure)":(i,n,a)=>A.encodeNumberArray(ae(i,x(a)),n)},YES:{PLAIN:(i,n)=>A.decodeToString(i,n),SPECK48_96CTR:(i,n,a)=>ue(A.decodeToNumberArray(i,n),H(a)),"SPECK32_64ECB (insecure)":(i,n,a)=>fe(A.decodeToNumberArray(i,n),x(a))}};