diff --git a/dist/web/assets/index-G7fqkm88.js b/dist/web/assets/index-G7fqkm88.js new file mode 100644 index 0000000..d0f0c10 --- /dev/null +++ b/dist/web/assets/index-G7fqkm88.js @@ -0,0 +1,4 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))g(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const s of f.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&g(s)}).observe(document,{childList:!0,subtree:!0});function c(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function g(u){if(u.ep)return;u.ep=!0;const f=c(u);fetch(u.href,f)}})();const I={3:{unifier:"­",0:"᠎",1:"​",2:"‍"},6:{unifier:"‌",0:"‍",1:"‏",2:"­",3:"⁠",4:"​",5:"‎"},7:{unifier:"‌",0:"‍",1:"‏",2:"­",3:"⁠",4:"​",5:"‎",6:"\uFEFF"},encodeString:(e,t=7)=>Array.from(e,c=>(+t==7?ge(c):c.codePointAt(0)).toString(t).split("").map(g=>I[t][g]).join("")).join(I[t].unifier),encodeNumberArray:(e,t=7)=>e.map(c=>c.toString(t).split("").map(g=>I[t][g]).join("")).join(I[t].unifier),decodeToString:(e,t=7)=>I.decodeToNumberArray(e,t).map(c=>String.fromCodePoint(+t==7?he(c):c)).join(""),decodeToNumberArray:(e,t=7)=>e.split(I[t].unifier).map(c=>Array.from(c).map(g=>Object.keys(I[t]).find(u=>I[t][u]===g)).join("")).filter(Boolean).map(c=>parseInt(c,t))},de="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",X=[...new Set([...de,...Array.from({length:95},(e,t)=>String.fromCharCode(t+32))])],pe=new Map(X.map((e,t)=>[e,t])),ge=e=>pe.get(e)??(e.codePointAt(0)<32?e.codePointAt(0)+95:e.codePointAt(0)),he=e=>e<95?X[e].codePointAt(0):e<127?e-95:e,J=65536;function Q(e,t,c){const g=[];for(let u=0;u=55296&&e.charCodeAt(f-1)<=56319&&f--,g.push(I[c](e.slice(u,f),t)),u=f}return g.join(I[t].unifier)}function ee(e,t,c){const g=[],u=I[t].unifier;for(let f=0;f=f?n+1:e.indexOf(u,s)+1||e.length}g.push(I[c](e.slice(f,s),t)),f=s}return c==="decodeToString"?g.join(""):g.flat()}const be=(e,t)=>Q(e,t,"encodeString"),M=(e,t)=>Q(e,t,"encodeNumberArray"),ye=(e,t)=>ee(e,t,"decodeToString"),v=(e,t)=>ee(e,t,"decodeToNumberArray");function me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var F,G;function Ae(){if(G)return F;G=1;function e(t={}){const c=t.bits||16,g=t.rounds||22,u=t.rightRotations||7,f=t.leftRotations||2,s=2**c,n=s-1,a=(l,o)=>l>>o|l<l<>c-o,m=(l,o,r)=>(l=a(l,u),l=l+o&n,l^=r,o=y(o,f),o^=l,[l,o]),w=(l,o,r)=>(o^=l,o=a(o,f),l^=r,l=l-o&n,l=y(l,u),[l,o]);function k(l,o){let r=l[0],d=l[1],i=o[0],h=o.slice(1);[d,r]=m(d,r,i);for(let b=0;b{const d=l([o/s|0,o&n],r);return d[0]*s+d[1]}}return{encrypt:p(k),decrypt:p(E),encryptRaw:k,decryptRaw:E}}return F=e,F}var we=Ae();const te=me(we);var P,K;function ne(){if(K)return P;K=1;const e="Input must be an string, Buffer or Uint8Array";function t(s){let n;if(s instanceof Uint8Array)n=s;else if(typeof s=="string")n=new TextEncoder().encode(s);else throw new Error(e);return n}function c(s){return Array.prototype.map.call(s,function(n){return(n<16?"0":"")+n.toString(16)}).join("")}function g(s){return(4294967296+s).toString(16).substring(1)}function u(s,n,a){let y=` +`+s+" = ";for(let m=0;m=4294967296&&b++,r[d]=h,r[d+1]=b}function c(r,d,i,h){let b=r[d]+i;i<0&&(b+=4294967296);let A=r[d+1]+h;b>=4294967296&&A++,r[d]=b,r[d+1]=A}function g(r,d){return r[d]^r[d+1]<<8^r[d+2]<<16^r[d+3]<<24}function u(r,d,i,h,b,A){const le=y[b],ae=y[b+1],ue=y[A],fe=y[A+1];t(a,r,d),c(a,r,le,ae);let S=a[h]^a[r],C=a[h+1]^a[r+1];a[h]=C,a[h+1]=S,t(a,i,h),S=a[d]^a[i],C=a[d+1]^a[i+1],a[d]=S>>>24^C<<8,a[d+1]=C>>>24^S<<8,t(a,r,d),c(a,r,ue,fe),S=a[h]^a[r],C=a[h+1]^a[r+1],a[h]=S>>>16^C<<16,a[h+1]=C>>>16^S<<16,t(a,i,h),S=a[d]^a[i],C=a[d+1]^a[i+1],a[d]=C>>>31^S<<1,a[d+1]=S>>>31^C<<1}const f=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],n=new Uint8Array(s.map(function(r){return r*2})),a=new Uint32Array(32),y=new Uint32Array(32);function m(r,d){let i=0;for(i=0;i<16;i++)a[i]=r.h[i],a[i+16]=f[i];for(a[24]=a[24]^r.t,a[25]=a[25]^r.t/4294967296,d&&(a[28]=~a[28],a[29]=~a[29]),i=0;i<32;i++)y[i]=g(r.b,4*i);for(i=0;i<12;i++)u(0,8,16,24,n[i*16+0],n[i*16+1]),u(2,10,18,26,n[i*16+2],n[i*16+3]),u(4,12,20,28,n[i*16+4],n[i*16+5]),u(6,14,22,30,n[i*16+6],n[i*16+7]),u(0,10,20,30,n[i*16+8],n[i*16+9]),u(2,12,22,24,n[i*16+10],n[i*16+11]),u(4,14,16,26,n[i*16+12],n[i*16+13]),u(6,8,18,28,n[i*16+14],n[i*16+15]);for(i=0;i<16;i++)r.h[i]=r.h[i]^a[i]^a[i+16]}const w=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 k(r,d,i,h){if(r===0||r>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(d&&d.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(i&&i.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(h&&h.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const b={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:r};w.fill(0),w[0]=r,d&&(w[1]=d.length),w[2]=1,w[3]=1,i&&w.set(i,32),h&&w.set(h,48);for(let A=0;A<16;A++)b.h[A]=f[A]^g(w,A*4);return d&&(E(b,d),b.c=128),b}function E(r,d){for(let i=0;i>2]>>8*(i&3);return d}function l(r,d,i,h,b){i=i||64,r=e.normalizeInput(r),h&&(h=e.normalizeInput(h)),b&&(b=e.normalizeInput(b));const A=k(i,d,h,b);return E(A,r),p(A)}function o(r,d,i,h,b){const A=l(r,d,i,h,b);return e.toHex(A)}return O={blake2b:l,blake2bHex:o,blake2bInit:k,blake2bUpdate:E,blake2bFinal:p},O}var R,z;function ke(){if(z)return R;z=1;const e=ne();function t(p,l){return p[l]^p[l+1]<<8^p[l+2]<<16^p[l+3]<<24}function c(p,l,o,r,d,i){s[p]=s[p]+s[l]+d,s[r]=g(s[r]^s[p],16),s[o]=s[o]+s[r],s[l]=g(s[l]^s[o],12),s[p]=s[p]+s[l]+i,s[r]=g(s[r]^s[p],8),s[o]=s[o]+s[r],s[l]=g(s[l]^s[o],7)}function g(p,l){return p>>>l^p<<32-l}const u=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),f=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),n=new Uint32Array(16);function a(p,l){let o=0;for(o=0;o<8;o++)s[o]=p.h[o],s[o+8]=u[o];for(s[12]^=p.t,s[13]^=p.t/4294967296,l&&(s[14]=~s[14]),o=0;o<16;o++)n[o]=t(p.b,4*o);for(o=0;o<10;o++)c(0,4,8,12,n[f[o*16+0]],n[f[o*16+1]]),c(1,5,9,13,n[f[o*16+2]],n[f[o*16+3]]),c(2,6,10,14,n[f[o*16+4]],n[f[o*16+5]]),c(3,7,11,15,n[f[o*16+6]],n[f[o*16+7]]),c(0,5,10,15,n[f[o*16+8]],n[f[o*16+9]]),c(1,6,11,12,n[f[o*16+10]],n[f[o*16+11]]),c(2,7,8,13,n[f[o*16+12]],n[f[o*16+13]]),c(3,4,9,14,n[f[o*16+14]],n[f[o*16+15]]);for(o=0;o<8;o++)p.h[o]^=s[o]^s[o+8]}function y(p,l){if(!(p>0&&p<=32))throw new Error("Incorrect output length, should be in [1, 32]");const o=l?l.length:0;if(l&&!(o>0&&o<=32))throw new Error("Incorrect key length, should be in [1, 32]");const r={h:new Uint32Array(u),b:new Uint8Array(64),c:0,t:0,outlen:p};return r.h[0]^=16842752^o<<8^p,o>0&&(m(r,l),r.c=64),r}function m(p,l){for(let o=0;o>2]>>8*(o&3)&255;return l}function k(p,l,o){o=o||32,p=e.normalizeInput(p);const r=y(o,l);return m(r,p),w(r)}function E(p,l,o){const r=k(p,l,o);return e.toHex(r)}return R={blake2s:k,blake2sHex:E,blake2sInit:y,blake2sUpdate:m,blake2sFinal:w},R}var _,$;function Ee(){if($)return _;$=1;const e=Ie(),t=ke();return _={blake2b:e.blake2b,blake2bHex:e.blake2bHex,blake2bInit:e.blake2bInit,blake2bUpdate:e.blake2bUpdate,blake2bFinal:e.blake2bFinal,blake2s:t.blake2s,blake2sHex:t.blake2sHex,blake2sInit:t.blake2sInit,blake2sUpdate:t.blake2sUpdate,blake2sFinal:t.blake2sFinal},_}var re=Ee();const oe=te({bits:24,rounds:23,rightRotations:8,leftRotations:3});function W(e){const t=re.blake2bHex(e,null,12);return[parseInt(t.slice(0,6),16),parseInt(t.slice(6,12),16),parseInt(t.slice(12,18),16),parseInt(t.slice(18,24),16)]}function Se(e,t){const c=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]&16777215,g=Array.from(e,(u,f)=>{const s=c*16777216+(f&16777215),n=oe.encrypt(s,t);return(u.codePointAt(0)^n)>>>0});return[c,...g]}function Ce(e,t){if(!e||e.length===0)return"";const c=e[0];return e.slice(1).map((u,f)=>{const s=c*16777216+(f&16777215),n=oe.encrypt(s,t),a=(u^n)>>>0;try{return String.fromCodePoint(a)}catch{return""}}).join("")}const ie=te();function Y(e){const t=re.blake2bHex(e,null,8);return[parseInt(t.slice(0,4),16),parseInt(t.slice(4,8),16),parseInt(t.slice(8,12),16),parseInt(t.slice(12,16),16)]}function Be(e,t){return Array.from(e,c=>ie.encrypt(c.codePointAt(0),t))}function Te(e,t){return e.map(c=>{try{return String.fromCodePoint(ie.decrypt(c,t))}catch{return""}}).join("")}const j="‍​­",B={3:"‍​­᠎‍",6:"‍​­‌‍",7:"‍​­‌‌"},ce={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"},Ue=Object.fromEntries(Object.entries(ce).map(([e,t])=>[t,+e]));function De(e,t){let c=B[e];const g=Ue[t];if(g){const u=Array.from(g.toString(e).padStart(3,"0"),f=>I[e][f]).join("");c+=I[e].unifier+I[e][0]+u}return c}function Fe(e){let t=e.indexOf(j),c;for(;t!==-1&&(c=Object.keys(B).find(f=>e.startsWith(B[f],t)),!c);)t=e.indexOf(j,t+j.length);if(!c)return null;const g=e.slice(t+B[c].length),u=I[c].unifier+I[c][0];if(g.startsWith(u)){const s=Array.from(g.slice(u.length,u.length+3)).map(m=>Object.keys(I[c]).find(w=>I[c][w]===m)).join(""),n=ce[parseInt(s,c)];if(!n)return{base:c,cipher:"PLAIN",payload:g,sigIdx:t,sigLen:B[c].length};const a=g.slice(u.length+3),y=B[c].length+u.length+3;return{base:c,cipher:n,payload:a,sigIdx:t,sigLen:y}}return{base:c,cipher:"PLAIN",payload:g,sigIdx:t,sigLen:B[c].length}}const T=document.getElementById("textarea"),N=document.getElementById("encoder"),L=document.getElementById("cipher"),H=document.getElementById("sign"),D=document.getElementById("sigDetect"),U=document.getElementById("notice"),Pe=["encodeButton","decodeButton"].map(e=>document.getElementById(e)),V=[...Pe,N,L,H];document.getElementById("encodeButton").addEventListener("click",se);document.getElementById("decodeButton").addEventListener("click",se);H.addEventListener("click",e=>e.target.classList.toggle("on"));let Z,x=!1;async function se(e){if(x)return;if(clearTimeout(Z),D.className="",T.value===""){T.value="The text box is empty.";return}const t=e.target.id==="encodeButton"?"NO":"YES";let c=Re(),g=N.value.split("-")[1],u=T.value;if(t==="YES"){const n=Fe(u);if(n){if(n.base!==g||n.cipher&&n.cipher!==c){const a=n.cipher&&n.cipher!=="PLAIN"?` (${n.cipher})`:"";D.textContent=`ZWUS-${n.base}${a} signature detected`,D.className="show",Z=setTimeout(()=>D.className="",2e3)}g=n.base,N.value="ZWUS-"+g,n.cipher&&(c=n.cipher,L.value=c),u=u.slice(0,n.sigIdx)+n.payload}}const f=c!=="PLAIN",s=f&&prompt("enter password.");if(!(f&&!s)){x=!0,V.forEach(n=>n.disabled=!0),U.textContent="Processing…";try{let n=await _e[t][c](u,g,s);if(t==="NO"&&H.classList.contains("on")&&(n=De(g,c)+n),T.value=n,t==="NO"){U.textContent="Copying…";const a=await Oe(n);a&&n.length<=65536&&(T.value=`Copied to your clipboard. + A copy has been placed between these brackets [`+n+"]"),U.textContent=a?`Copied ${n.length.toLocaleString()} characters.`:"Copy failed. The encoded text is in the box; select and copy it manually."}else U.textContent=`Decoded ${n.length.toLocaleString()} characters.`}catch(n){console.error(n),U.textContent=`Could not ${t==="NO"?"encode":"decode"}: ${n.message}`}finally{x=!1,V.forEach(n=>n.disabled=!1)}}}async function Oe(e){var t;if((t=navigator.clipboard)!=null&&t.writeText){let c;try{return await Promise.race([navigator.clipboard.writeText(e),new Promise((g,u)=>c=setTimeout(()=>u(new Error("Copy timed out")),5e3))]),!0}catch(g){console.warn("Clipboard copy failed",g)}finally{clearTimeout(c)}}if(e.length>65536)return!1;T.select();try{return document.execCommand("copy")}catch(c){return console.warn("Clipboard copy failed",c),!1}}function Re(){return L.value}const _e={NO:{PLAIN:(e,t)=>be(e,t),SPECK48_96CTR:(e,t,c)=>M(Se(e,W(c)),t),"SPECK32_64ECB (insecure)":(e,t,c)=>M(Be(e,Y(c)),t)},YES:{PLAIN:(e,t)=>ye(e,t),SPECK48_96CTR:async(e,t,c)=>Ce(await v(e,t),W(c)),"SPECK32_64ECB (insecure)":async(e,t,c)=>Te(await v(e,t),Y(c))}}; diff --git a/dist/web/assets/index-wRI3Wnct.js b/dist/web/assets/index-wRI3Wnct.js deleted file mode 100644 index 53fd572..0000000 --- a/dist/web/assets/index-wRI3Wnct.js +++ /dev/null @@ -1,4 +0,0 @@ -(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<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{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=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>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>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))}}; diff --git a/dist/web/index.html b/dist/web/index.html index 5411506..35b4778 100644 --- a/dist/web/index.html +++ b/dist/web/index.html @@ -3,19 +3,19 @@ - + -

inØsight 3.1.0source

+

inØsight 3.2.0source