From 652d55cdd76690af41bb29b1984a598febf90c04 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Sat, 12 Sep 2026 17:46:28 -0700 Subject: [PATCH] feat: in-page detection with overlay UI and 5-char signatures --- content.js | 215 ++++++++++++++++++++++++++++++ dash.js | 28 ++-- dist/chrome/content.js | 54 ++++++++ dist/chrome/index.js | 8 +- dist/chrome/manifest.json | 2 +- dist/firefox/content.js | 54 ++++++++ dist/firefox/index.css | 2 +- dist/firefox/index.js | 8 +- dist/firefox/manifest.json | 2 +- dist/web/assets/index-CZZybJ_s.js | 4 - dist/web/assets/index-wRI3Wnct.js | 4 + dist/web/index.html | 64 ++++----- sig.js | 53 ++++++++ vite.config.js | 8 ++ 14 files changed, 445 insertions(+), 61 deletions(-) create mode 100644 content.js create mode 100644 dist/chrome/content.js create mode 100644 dist/firefox/content.js delete mode 100644 dist/web/assets/index-CZZybJ_s.js create mode 100644 dist/web/assets/index-wRI3Wnct.js create mode 100644 sig.js diff --git a/content.js b/content.js new file mode 100644 index 0000000..0104364 --- /dev/null +++ b/content.js @@ -0,0 +1,215 @@ +import zwus from 'zwus'; +import * as speck48_96ctr from './speck48_96ctr.js'; +import * as speck32_64ecb from './speck32_64ecb.js'; +import { SIG_PREFIX, parseSig, getPayloadEnd } from './sig.js'; + +let host, shadow; +const active = new Set(); + +function initShadow() { + if (host) return; + host = document.createElement('div'); + host.id = 'in0-host'; + shadow = host.attachShadow({ mode: 'open' }); + const s = document.createElement('style'); + s.textContent = ` + .in0-wrap { + position: absolute; + pointer-events: auto; + z-index: 2147483647; + display: flex; + flex-direction: column; + align-items: center; + font-family: system-ui, -apple-system, sans-serif; + } + .in0-btn { + background: #18191c; + color: #fff; + border: 1px solid #3a3b40; + border-radius: 4px; + font-size: 11px; + font-weight: 600; + padding: 4px 10px; + cursor: pointer; + box-shadow: 0 4px 12px rgba(0,0,0,0.5); + position: relative; + white-space: nowrap; + } + .in0-btn:hover { + border-color: #00b4d8; + box-shadow: 0 0 8px rgba(0,180,216,0.4); + } + .in0-badge { + position: absolute; + top: -6px; + right: -6px; + width: 15px; + height: 15px; + border-radius: 50%; + background: #00b4d8; + color: #fff; + font-size: 10px; + font-weight: 700; + display: flex; + align-items: center; + justify-content: center; + box-shadow: 0 1px 3px rgba(0,0,0,0.4); + } + .in0-arrow { + width: 0; + height: 0; + border-left: 5px solid transparent; + border-right: 5px solid transparent; + border-top: 6px solid #18191c; + margin-top: -1px; + } + `; + shadow.appendChild(s); + (document.body || document.documentElement).appendChild(host); +} + +function createOverlay(node, parsed, start, end) { + initShadow(); + const wrap = document.createElement('div'); + wrap.className = 'in0-wrap'; + + const btn = document.createElement('button'); + btn.className = 'in0-btn'; + btn.textContent = parsed.cipher === 'PLAIN' ? 'Decode' : 'Decrypt'; + + const badge = document.createElement('span'); + badge.className = 'in0-badge'; + badge.textContent = '\u00D8'; + btn.appendChild(badge); + + const arrow = document.createElement('div'); + arrow.className = 'in0-arrow'; + + wrap.appendChild(btn); + wrap.appendChild(arrow); + shadow.appendChild(wrap); + + const entry = { wrap, node, start, end }; + active.add(entry); + + btn.onclick = () => onAction(entry, parsed); + updatePos(entry); +} + +function updatePos(entry) { + const { wrap, node, start, end } = entry; + if (!node.isConnected) { + wrap.remove(); + active.delete(entry); + return; + } + const r = document.createRange(); + try { + r.setStart(node, start); + r.setEnd(node, Math.min(end, node.nodeValue.length)); + } catch { + wrap.remove(); + active.delete(entry); + return; + } + let rect = r.getBoundingClientRect(); + if (!rect.width && !rect.height && node.parentElement) { + rect = node.parentElement.getBoundingClientRect(); + } + const x = rect.left + window.scrollX + (rect.width || 0) / 2; + const y = rect.top + window.scrollY; + wrap.style.left = `${x - wrap.offsetWidth / 2}px`; + wrap.style.top = `${y - wrap.offsetHeight - 2}px`; +} + +function onAction(entry, parsed) { + const { wrap, node, start, end } = entry; + const rawPayload = node.nodeValue.slice(start + parsed.sigLen, end); + let decoded = ''; + + if (parsed.cipher === 'PLAIN') { + try { + decoded = zwus.decodeToString(rawPayload, parsed.base); + } catch (e) { + console.error(e); + } + } else { + const pass = prompt(`in\u00D8sight: enter password (${parsed.cipher}):`); + if (!pass) return; + try { + const arr = zwus.decodeToNumberArray(rawPayload, parsed.base); + if (parsed.cipher === 'SPECK48_96CTR') + decoded = speck48_96ctr.decrypt(arr, speck48_96ctr.getKey(pass)); + else if (parsed.cipher === 'SPECK32_64ECB (insecure)') + decoded = speck32_64ecb.decrypt(arr, speck32_64ecb.getKey(pass)); + } catch (e) { + console.error(e); + } + if (!decoded) { + alert('Decryption failed.'); + return; + } + } + + if (decoded) { + const r = document.createRange(); + r.setStart(node, start); + r.setEnd(node, end); + r.deleteContents(); + const span = document.createElement('span'); + span.className = 'inzerosight-decoded'; + span.style.color = '#00b4d8'; + span.style.fontWeight = '600'; + span.textContent = ` ${decoded} `; + r.insertNode(span); + wrap.remove(); + active.delete(entry); + } +} + +const scanned = new WeakSet(); + +function scanNode(node) { + if (!node || node.nodeType !== Node.TEXT_NODE || scanned.has(node)) return; + const val = node.nodeValue; + if (!val || !val.includes(SIG_PREFIX)) return; + + scanned.add(node); + let idx = 0; + while (idx < val.length) { + const sub = val.slice(idx); + const p = parseSig(sub); + if (!p) break; + const start = idx + p.sigIdx; + const end = getPayloadEnd(val, p.base, start + p.sigLen); + createOverlay(node, p, start, end); + idx = end + 1; + } +} + +function scanTree(root) { + if (!root) return; + const ign = { SCRIPT: 1, STYLE: 1, TEXTAREA: 1, INPUT: 1, NOSCRIPT: 1, 'IN0-HOST': 1 }; + const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, { + acceptNode: n => (ign[n.parentElement?.tagName] ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT) + }); + let n; + while ((n = walker.nextNode())) scanNode(n); +} + +scanTree(document.body); + +const obs = new MutationObserver(muts => { + for (const m of muts) { + if (m.type === 'characterData') scanNode(m.target); + else for (const an of m.addedNodes) { + if (an.nodeType === Node.TEXT_NODE) scanNode(an); + else if (an.nodeType === Node.ELEMENT_NODE && an.id !== 'in0-host') scanTree(an); + } + } +}); + +obs.observe(document.documentElement, { childList: true, subtree: true, characterData: true }); + +window.addEventListener('scroll', () => active.forEach(updatePos), { passive: true }); +window.addEventListener('resize', () => active.forEach(updatePos), { passive: true }); diff --git a/dash.js b/dash.js index 5037b43..bc36ba7 100644 --- a/dash.js +++ b/dash.js @@ -1,6 +1,7 @@ import zwus from 'zwus'; import * as speck48_96ctr from './speck48_96ctr.js'; import * as speck32_64ecb from './speck32_64ecb.js'; +import { makeSig, parseSig } from './sig.js'; const textarea = document.getElementById('textarea'); const encoderDropdown = document.getElementById('encoder'); @@ -8,12 +9,6 @@ const cipherDropdown = document.getElementById('cipher'); const signBtn = document.getElementById('sign'); const sigDetect = document.getElementById('sigDetect'); -const SIG = { - 3: '\u{200D}\u{200B}\u{00AD}\u{180E}', - 6: '\u{200D}\u{200B}\u{00AD}\u{2060}', - 8: '\u{200D}\u{200B}\u{00AD}\u{FEFF}' -}; - document.getElementById('encodeButton').addEventListener('click', ACT); document.getElementById('decodeButton').addEventListener('click', ACT); signBtn.addEventListener('click', e => @@ -32,23 +27,28 @@ function ACT(event) { } const op = event.target.id === 'encodeButton' ? 'NO' : 'YES'; - const cipher = getCipherKey(); + let cipher = getCipherKey(); let base = encoderDropdown.value.split('-')[1]; let text = textarea.value; if (op === 'YES') { - const sigBase = Object.keys(SIG).find(b => text.includes(SIG[b])); - if (sigBase) { - if (sigBase !== base) { - sigDetect.textContent = `ZWUS-${sigBase} signature detected`; + const parsed = parseSig(text); + if (parsed) { + if (parsed.base !== base || (parsed.cipher && parsed.cipher !== cipher)) { + const desc = parsed.cipher && parsed.cipher !== 'PLAIN' ? ` (${parsed.cipher})` : ''; + sigDetect.textContent = `ZWUS-${parsed.base}${desc} signature detected`; sigDetect.className = 'show'; fadeTimer = setTimeout(() => sigDetect.className = '', 2000 ); } - base = sigBase; + base = parsed.base; encoderDropdown.value = 'ZWUS-' + base; - text = text.replace(SIG[base], ''); + if (parsed.cipher) { + cipher = parsed.cipher; + cipherDropdown.value = cipher; + } + text = text.slice(0, parsed.sigIdx) + parsed.payload; } } @@ -60,7 +60,7 @@ function ACT(event) { try { let val = DESCRY[op][cipher](text, base, kStr); if (op === 'NO' && signBtn.classList.contains('on')) - val = SIG[base] + val; + val = makeSig(base, cipher) + val; textarea.value = val; } catch (e) { console.log(e); diff --git a/dist/chrome/content.js b/dist/chrome/content.js new file mode 100644 index 0000000..869442e --- /dev/null +++ b/dist/chrome/content.js @@ -0,0 +1,54 @@ +(function(){"use strict";const y={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:(o,e=3)=>Array.from(o,l=>l.codePointAt(0).toString(e).split("").map(b=>y[e][b]).join("")).join(y[e].unifier),encodeNumberArray:(o,e=3)=>o.map(l=>l.toString(e).split("").map(b=>y[e][b]).join("")).join(y[e].unifier),decodeToString:(o,e=3)=>o.split(y[e].unifier).map(l=>String.fromCodePoint(parseInt(Array.from(l).map(b=>Object.keys(y[e]).find(d=>y[e][d]===b)).join(""),e))).join(""),decodeToNumberArray:(o,e=3)=>o.split(y[e].unifier).map(l=>parseInt(Array.from(l).map(b=>Object.keys(y[e]).find(d=>y[e][d]===b)).join(""),e))};function V(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var D,P;function Y(){if(P)return D;P=1;function o(e={}){const l=e.bits||16,b=e.rounds||22,d=e.rightRotations||7,p=e.leftRotations||2,c=2**l,s=c-1,i=(a,n)=>a>>n|a<a<>l-n,m=(a,n,t)=>(a=i(a,d),a=a+n&s,a^=t,n=h(n,p),n^=a,[a,n]),E=(a,n,t)=>(n^=a,n=i(n,p),a^=t,a=a-n&s,a=h(a,d),[a,n]);function I(a,n){let t=a[0],u=a[1],r=n[0],g=n.slice(1);[u,t]=m(u,t,r);for(let w=0;w{const u=a([n/c|0,n&s],t);return u[0]*c+u[1]}}return{encrypt:f(I),decrypt:f(A),encryptRaw:I,decryptRaw:A}}return D=o,D}var J=Y();const v=V(J);var U,H;function L(){if(H)return U;H=1;const o="Input must be an string, Buffer or Uint8Array";function e(c){let s;if(c instanceof Uint8Array)s=c;else if(typeof c=="string")s=new TextEncoder().encode(c);else throw new Error(o);return s}function l(c){return Array.prototype.map.call(c,function(s){return(s<16?"0":"")+s.toString(16)}).join("")}function b(c){return(4294967296+c).toString(16).substring(1)}function d(c,s,i){let h=` +`+c+" = ";for(let m=0;m=4294967296&&w++,t[u]=g,t[u+1]=w}function l(t,u,r,g){let w=t[u]+r;r<0&&(w+=4294967296);let k=t[u+1]+g;w>=4294967296&&k++,t[u]=w,t[u+1]=k}function b(t,u){return t[u]^t[u+1]<<8^t[u+2]<<16^t[u+3]<<24}function d(t,u,r,g,w,k){const de=h[w],pe=h[w+1],be=h[k],he=h[k+1];e(i,t,u),l(i,t,de,pe);let S=i[g]^i[t],T=i[g+1]^i[t+1];i[g]=T,i[g+1]=S,e(i,r,g),S=i[u]^i[r],T=i[u+1]^i[r+1],i[u]=S>>>24^T<<8,i[u+1]=T>>>24^S<<8,e(i,t,u),l(i,t,be,he),S=i[g]^i[t],T=i[g+1]^i[t+1],i[g]=S>>>16^T<<16,i[g+1]=T>>>16^S<<16,e(i,r,g),S=i[u]^i[r],T=i[u+1]^i[r+1],i[u]=T>>>31^S<<1,i[u+1]=S>>>31^T<<1}const p=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=[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],s=new Uint8Array(c.map(function(t){return t*2})),i=new Uint32Array(32),h=new Uint32Array(32);function m(t,u){let r=0;for(r=0;r<16;r++)i[r]=t.h[r],i[r+16]=p[r];for(i[24]=i[24]^t.t,i[25]=i[25]^t.t/4294967296,u&&(i[28]=~i[28],i[29]=~i[29]),r=0;r<32;r++)h[r]=b(t.b,4*r);for(r=0;r<12;r++)d(0,8,16,24,s[r*16+0],s[r*16+1]),d(2,10,18,26,s[r*16+2],s[r*16+3]),d(4,12,20,28,s[r*16+4],s[r*16+5]),d(6,14,22,30,s[r*16+6],s[r*16+7]),d(0,10,20,30,s[r*16+8],s[r*16+9]),d(2,12,22,24,s[r*16+10],s[r*16+11]),d(4,14,16,26,s[r*16+12],s[r*16+13]),d(6,8,18,28,s[r*16+14],s[r*16+15]);for(r=0;r<16;r++)t.h[r]=t.h[r]^i[r]^i[r+16]}const E=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 I(t,u,r,g){if(t===0||t>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 w={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t};E.fill(0),E[0]=t,u&&(E[1]=u.length),E[2]=1,E[3]=1,r&&E.set(r,32),g&&E.set(g,48);for(let k=0;k<16;k++)w.h[k]=p[k]^b(E,k*4);return u&&(A(w,u),w.c=128),w}function A(t,u){for(let r=0;r>2]>>8*(r&3);return u}function a(t,u,r,g,w){r=r||64,t=o.normalizeInput(t),g&&(g=o.normalizeInput(g)),w&&(w=o.normalizeInput(w));const k=I(r,u,g,w);return A(k,t),f(k)}function n(t,u,r,g,w){const k=a(t,u,r,g,w);return o.toHex(k)}return B={blake2b:a,blake2bHex:n,blake2bInit:I,blake2bUpdate:A,blake2bFinal:f},B}var N,z;function Z(){if(z)return N;z=1;const o=L();function e(f,a){return f[a]^f[a+1]<<8^f[a+2]<<16^f[a+3]<<24}function l(f,a,n,t,u,r){c[f]=c[f]+c[a]+u,c[t]=b(c[t]^c[f],16),c[n]=c[n]+c[t],c[a]=b(c[a]^c[n],12),c[f]=c[f]+c[a]+r,c[t]=b(c[t]^c[f],8),c[n]=c[n]+c[t],c[a]=b(c[a]^c[n],7)}function b(f,a){return f>>>a^f<<32-a}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]),c=new Uint32Array(16),s=new Uint32Array(16);function i(f,a){let n=0;for(n=0;n<8;n++)c[n]=f.h[n],c[n+8]=d[n];for(c[12]^=f.t,c[13]^=f.t/4294967296,a&&(c[14]=~c[14]),n=0;n<16;n++)s[n]=e(f.b,4*n);for(n=0;n<10;n++)l(0,4,8,12,s[p[n*16+0]],s[p[n*16+1]]),l(1,5,9,13,s[p[n*16+2]],s[p[n*16+3]]),l(2,6,10,14,s[p[n*16+4]],s[p[n*16+5]]),l(3,7,11,15,s[p[n*16+6]],s[p[n*16+7]]),l(0,5,10,15,s[p[n*16+8]],s[p[n*16+9]]),l(1,6,11,12,s[p[n*16+10]],s[p[n*16+11]]),l(2,7,8,13,s[p[n*16+12]],s[p[n*16+13]]),l(3,4,9,14,s[p[n*16+14]],s[p[n*16+15]]);for(n=0;n<8;n++)f.h[n]^=c[n]^c[n+8]}function h(f,a){if(!(f>0&&f<=32))throw new Error("Incorrect output length, should be in [1, 32]");const n=a?a.length:0;if(a&&!(n>0&&n<=32))throw new Error("Incorrect key length, should be in [1, 32]");const t={h:new Uint32Array(d),b:new Uint8Array(64),c:0,t:0,outlen:f};return t.h[0]^=16842752^n<<8^f,n>0&&(m(t,a),t.c=64),t}function m(f,a){for(let n=0;n>2]>>8*(n&3)&255;return a}function I(f,a,n){n=n||32,f=o.normalizeInput(f);const t=h(n,a);return m(t,f),E(t)}function A(f,a,n){const t=I(f,a,n);return o.toHex(t)}return N={blake2s:I,blake2sHex:A,blake2sInit:h,blake2sUpdate:m,blake2sFinal:E},N}var _,G;function ee(){if(G)return _;G=1;const o=Q(),e=Z();return _={blake2b:o.blake2b,blake2bHex:o.blake2bHex,blake2bInit:o.blake2bInit,blake2bUpdate:o.blake2bUpdate,blake2bFinal:o.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},_}var q=ee();const te=v({bits:24,rounds:23,rightRotations:8,leftRotations:3});function ne(o){const e=q.blake2bHex(o,null,12);return[parseInt(e.slice(0,6),16),parseInt(e.slice(6,12),16),parseInt(e.slice(12,18),16),parseInt(e.slice(18,24),16)]}function re(o,e){if(!o||o.length===0)return"";const l=o[0];return o.slice(1).map((d,p)=>{const c=l*16777216+(p&16777215),s=te.encrypt(c,e),i=(d^s)>>>0;try{return String.fromCodePoint(i)}catch{return""}}).join("")}const oe=v();function ie(o){const e=q.blake2bHex(o,null,8);return[parseInt(e.slice(0,4),16),parseInt(e.slice(4,8),16),parseInt(e.slice(8,12),16),parseInt(e.slice(12,16),16)]}function se(o,e){return o.map(l=>{try{return String.fromCodePoint(oe.decrypt(l,e))}catch{return""}}).join("")}const K="‍​­",C={3:"‍​­᠎‍",6:"‍​­‌‍",8:"‍​­‌‌"},X={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(X).map(([o,e])=>[e,+o]));function ce(o){if(!o.includes(K))return null;const e=Object.keys(C).find(p=>o.includes(C[p]));if(!e)return null;const l=o.indexOf(C[e]),b=o.slice(l+C[e].length),d=y[e].unifier+y[e][0];if(b.startsWith(d)){const c=Array.from(b.slice(d.length,d.length+3)).map(m=>Object.keys(y[e]).find(E=>y[e][E]===m)).join(""),s=X[parseInt(c,e)],i=b.slice(d.length+3),h=C[e].length+d.length+3;return{base:e,cipher:s,payload:i,sigIdx:l,sigLen:h}}return{base:e,cipher:"PLAIN",payload:b,sigIdx:l,sigLen:C[e].length}}function ae(o,e,l){const b=new Set(Object.values(y[e]));let d=l;for(;dfe(i,e),F(i)}function F(o){const{wrap:e,node:l,start:b,end:d}=o;if(!l.isConnected){e.remove(),x.delete(o);return}const p=document.createRange();try{p.setStart(l,b),p.setEnd(l,Math.min(d,l.nodeValue.length))}catch{e.remove(),x.delete(o);return}let c=p.getBoundingClientRect();!c.width&&!c.height&&l.parentElement&&(c=l.parentElement.getBoundingClientRect());const s=c.left+window.scrollX+(c.width||0)/2,i=c.top+window.scrollY;e.style.left=`${s-e.offsetWidth/2}px`,e.style.top=`${i-e.offsetHeight-2}px`}function fe(o,e){const{wrap:l,node:b,start:d,end:p}=o,c=b.nodeValue.slice(d+e.sigLen,p);let s="";if(e.cipher==="PLAIN")try{s=y.decodeToString(c,e.base)}catch(i){console.error(i)}else{const i=prompt(`inØsight: enter password (${e.cipher}):`);if(!i)return;try{const h=y.decodeToNumberArray(c,e.base);e.cipher==="SPECK48_96CTR"?s=re(h,ne(i)):e.cipher==="SPECK32_64ECB (insecure)"&&(s=se(h,ie(i)))}catch(h){console.error(h)}if(!s){alert("Decryption failed.");return}}if(s){const i=document.createRange();i.setStart(b,d),i.setEnd(b,p),i.deleteContents();const h=document.createElement("span");h.className="inzerosight-decoded",h.style.color="#00b4d8",h.style.fontWeight="600",h.textContent=` ${s} `,i.insertNode(h),l.remove(),x.delete(o)}}const W=new WeakSet;function O(o){if(!o||o.nodeType!==Node.TEXT_NODE||W.has(o))return;const e=o.nodeValue;if(!e||!e.includes(K))return;W.add(o);let l=0;for(;l{var p;return e[(p=d.parentElement)==null?void 0:p.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let b;for(;b=l.nextNode();)O(b)}$(document.body),new MutationObserver(o=>{for(const e of o)if(e.type==="characterData")O(e.target);else for(const l of e.addedNodes)l.nodeType===Node.TEXT_NODE?O(l):l.nodeType===Node.ELEMENT_NODE&&l.id!=="in0-host"&&$(l)}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",()=>x.forEach(F),{passive:!0}),window.addEventListener("resize",()=>x.forEach(F),{passive:!0})})(); diff --git a/dist/chrome/index.js b/dist/chrome/index.js index 001cd0b..53fd572 100644 --- a/dist/chrome/index.js +++ b/dist/chrome/index.js @@ -1,4 +1,4 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))p(d);new MutationObserver(d=>{for(const b of d)if(b.type==="childList")for(const s of b.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&p(s)}).observe(document,{childList:!0,subtree:!0});function f(d){const b={};return d.integrity&&(b.integrity=d.integrity),d.referrerPolicy&&(b.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?b.credentials="include":d.crossOrigin==="anonymous"?b.credentials="omit":b.credentials="same-origin",b}function p(d){if(d.ep)return;d.ep=!0;const b=f(d);fetch(d.href,b)}})();const w={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:(c,r=3)=>Array.from(c,f=>f.codePointAt(0).toString(r).split("").map(p=>w[r][p]).join("")).join(w[r].unifier),encodeNumberArray:(c,r=3)=>c.map(f=>f.toString(r).split("").map(p=>w[r][p]).join("")).join(w[r].unifier),decodeToString:(c,r=3)=>c.split(w[r].unifier).map(f=>String.fromCodePoint(parseInt(Array.from(f).map(p=>Object.keys(w[r]).find(d=>w[r][d]===p)).join(""),r))).join(""),decodeToNumberArray:(c,r=3)=>c.split(w[r].unifier).map(f=>parseInt(Array.from(f).map(p=>Object.keys(w[r]).find(d=>w[r][d]===p)).join(""),r))};function ee(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}var T,_;function te(){if(_)return T;_=1;function c(r={}){const f=r.bits||16,p=r.rounds||22,d=r.rightRotations||7,b=r.leftRotations||2,s=2**f,o=s-1,l=(i,t)=>i>>t|i<i<>f-t,k=(i,t,e)=>(i=l(i,d),i=i+t&o,i^=e,t=m(t,b),t^=i,[i,t]),A=(i,t,e)=>(t^=i,t=l(t,b),i^=e,i=i-t&o,i=m(i,d),[i,t]);function I(i,t){let e=i[0],u=i[1],n=t[0],g=t.slice(1);[u,e]=k(u,e,n);for(let h=0;h{const u=i([t/s|0,t&o],e);return u[0]*s+u[1]}}return{encrypt:a(I),decrypt:a(E),encryptRaw:I,decryptRaw:E}}return T=c,T}var ne=te();const G=ee(ne);var C,N;function K(){if(N)return C;N=1;const c="Input must be an string, Buffer or Uint8Array";function r(s){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=new TextEncoder().encode(s);else throw new Error(c);return o}function f(s){return Array.prototype.map.call(s,function(o){return(o<16?"0":"")+o.toString(16)}).join("")}function p(s){return(4294967296+s).toString(16).substring(1)}function d(s,o,l){let m=` -`+s+" = ";for(let k=0;k=4294967296&&h++,e[u]=g,e[u+1]=h}function f(e,u,n,g){let h=e[u]+n;n<0&&(h+=4294967296);let y=e[u+1]+g;h>=4294967296&&y++,e[u]=h,e[u+1]=y}function p(e,u){return e[u]^e[u+1]<<8^e[u+2]<<16^e[u+3]<<24}function d(e,u,n,g,h,y){const Z=m[h],X=m[h+1],J=m[y],Q=m[y+1];r(l,e,u),f(l,e,Z,X);let B=l[g]^l[e],S=l[g+1]^l[e+1];l[g]=S,l[g+1]=B,r(l,n,g),B=l[u]^l[n],S=l[u+1]^l[n+1],l[u]=B>>>24^S<<8,l[u+1]=S>>>24^B<<8,r(l,e,u),f(l,e,J,Q),B=l[g]^l[e],S=l[g+1]^l[e+1],l[g]=B>>>16^S<<16,l[g+1]=S>>>16^B<<16,r(l,n,g),B=l[u]^l[n],S=l[u+1]^l[n+1],l[u]=S>>>31^B<<1,l[u+1]=B>>>31^S<<1}const b=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 k(e,u){let n=0;for(n=0;n<16;n++)l[n]=e.h[n],l[n+16]=b[n];for(l[24]=l[24]^e.t,l[25]=l[25]^e.t/4294967296,u&&(l[28]=~l[28],l[29]=~l[29]),n=0;n<32;n++)m[n]=p(e.b,4*n);for(n=0;n<12;n++)d(0,8,16,24,o[n*16+0],o[n*16+1]),d(2,10,18,26,o[n*16+2],o[n*16+3]),d(4,12,20,28,o[n*16+4],o[n*16+5]),d(6,14,22,30,o[n*16+6],o[n*16+7]),d(0,10,20,30,o[n*16+8],o[n*16+9]),d(2,12,22,24,o[n*16+10],o[n*16+11]),d(4,14,16,26,o[n*16+12],o[n*16+13]),d(6,8,18,28,o[n*16+14],o[n*16+15]);for(n=0;n<16;n++)e.h[n]=e.h[n]^l[n]^l[n+16]}const A=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 I(e,u,n,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(n&&n.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};A.fill(0),A[0]=e,u&&(A[1]=u.length),A[2]=1,A[3]=1,n&&A.set(n,32),g&&A.set(g,48);for(let y=0;y<16;y++)h.h[y]=b[y]^p(A,y*4);return u&&(E(h,u),h.c=128),h}function E(e,u){for(let n=0;n>2]>>8*(n&3);return u}function i(e,u,n,g,h){n=n||64,e=c.normalizeInput(e),g&&(g=c.normalizeInput(g)),h&&(h=c.normalizeInput(h));const y=I(n,u,g,h);return E(y,e),a(y)}function t(e,u,n,g,h){const y=i(e,u,n,g,h);return c.toHex(y)}return D={blake2b:i,blake2bHex:t,blake2bInit:I,blake2bUpdate:E,blake2bFinal:a},D}var O,v;function oe(){if(v)return O;v=1;const c=K();function r(a,i){return a[i]^a[i+1]<<8^a[i+2]<<16^a[i+3]<<24}function f(a,i,t,e,u,n){s[a]=s[a]+s[i]+u,s[e]=p(s[e]^s[a],16),s[t]=s[t]+s[e],s[i]=p(s[i]^s[t],12),s[a]=s[a]+s[i]+n,s[e]=p(s[e]^s[a],8),s[t]=s[t]+s[e],s[i]=p(s[i]^s[t],7)}function p(a,i){return a>>>i^a<<32-i}const d=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),b=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(a,i){let t=0;for(t=0;t<8;t++)s[t]=a.h[t],s[t+8]=d[t];for(s[12]^=a.t,s[13]^=a.t/4294967296,i&&(s[14]=~s[14]),t=0;t<16;t++)o[t]=r(a.b,4*t);for(t=0;t<10;t++)f(0,4,8,12,o[b[t*16+0]],o[b[t*16+1]]),f(1,5,9,13,o[b[t*16+2]],o[b[t*16+3]]),f(2,6,10,14,o[b[t*16+4]],o[b[t*16+5]]),f(3,7,11,15,o[b[t*16+6]],o[b[t*16+7]]),f(0,5,10,15,o[b[t*16+8]],o[b[t*16+9]]),f(1,6,11,12,o[b[t*16+10]],o[b[t*16+11]]),f(2,7,8,13,o[b[t*16+12]],o[b[t*16+13]]),f(3,4,9,14,o[b[t*16+14]],o[b[t*16+15]]);for(t=0;t<8;t++)a.h[t]^=s[t]^s[t+8]}function m(a,i){if(!(a>0&&a<=32))throw new Error("Incorrect output length, should be in [1, 32]");const t=i?i.length:0;if(i&&!(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:a};return e.h[0]^=16842752^t<<8^a,t>0&&(k(e,i),e.c=64),e}function k(a,i){for(let t=0;t>2]>>8*(t&3)&255;return i}function I(a,i,t){t=t||32,a=c.normalizeInput(a);const e=m(t,i);return k(e,a),A(e)}function E(a,i,t){const e=I(a,i,t);return c.toHex(e)}return O={blake2s:I,blake2sHex:E,blake2sInit:m,blake2sUpdate:k,blake2sFinal:A},O}var j,x;function ie(){if(x)return j;x=1;const c=re(),r=oe();return j={blake2b:c.blake2b,blake2bHex:c.blake2bHex,blake2bInit:c.blake2bInit,blake2bUpdate:c.blake2bUpdate,blake2bFinal:c.blake2bFinal,blake2s:r.blake2s,blake2sHex:r.blake2sHex,blake2sInit:r.blake2sInit,blake2sUpdate:r.blake2sUpdate,blake2sFinal:r.blake2sFinal},j}var z=ie();const Y=G({bits:24,rounds:23,rightRotations:8,leftRotations:3});function H(c){const r=z.blake2bHex(c,null,12);return[parseInt(r.slice(0,6),16),parseInt(r.slice(6,12),16),parseInt(r.slice(12,18),16),parseInt(r.slice(18,24),16)]}function ce(c,r){const f=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]&16777215,p=Array.from(c,(d,b)=>{const s=f*16777216+(b&16777215),o=Y.encrypt(s,r);return(d.codePointAt(0)^o)>>>0});return[f,...p]}function se(c,r){if(!c||c.length===0)return"";const f=c[0];return c.slice(1).map((d,b)=>{const s=f*16777216+(b&16777215),o=Y.encrypt(s,r),l=(d^o)>>>0;try{return String.fromCodePoint(l)}catch{return""}}).join("")}const $=G();function L(c){const r=z.blake2bHex(c,null,8);return[parseInt(r.slice(0,4),16),parseInt(r.slice(4,8),16),parseInt(r.slice(8,12),16),parseInt(r.slice(12,16),16)]}function le(c,r){return Array.from(c,f=>$.encrypt(f.codePointAt(0),r))}function ue(c,r){return c.map(f=>{try{return String.fromCodePoint($.decrypt(f,r))}catch{return""}}).join("")}const U=document.getElementById("textarea"),M=document.getElementById("encoder"),ae=document.getElementById("cipher"),V=document.getElementById("sign"),F=document.getElementById("sigDetect"),R={3:"‍​­᠎",6:"‍​­⁠",8:"‍​­\uFEFF"};document.getElementById("encodeButton").addEventListener("click",W);document.getElementById("decodeButton").addEventListener("click",W);V.addEventListener("click",c=>c.target.classList.toggle("on"));let q;function W(c){if(clearTimeout(q),F.className="",U.value===""){U.value="The text box is empty.";return}const r=c.target.id==="encodeButton"?"NO":"YES",f=fe();let p=M.value.split("-")[1],d=U.value;if(r==="YES"){const o=Object.keys(R).find(l=>d.includes(R[l]));o&&(o!==p&&(F.textContent=`ZWUS-${o} signature detected`,F.className="show",q=setTimeout(()=>F.className="",2e3)),p=o,M.value="ZWUS-"+p,d=d.replace(R[p],""))}const b=f!=="PLAIN",s=b&&prompt("enter password.");if(!(b&&!s)){try{let o=de[r][f](d,p,s);r==="NO"&&V.classList.contains("on")&&(o=R[p]+o),U.value=o}catch(o){console.log(o)}r==="NO"&&(U.select(),document.execCommand("copy"),U.value=`Copied to your clipboard. - A copy has been placed between these brackets [`+U.value+"]")}}function fe(){return ae.value}const de={NO:{PLAIN:(c,r)=>w.encodeString(c,r),SPECK48_96CTR:(c,r,f)=>w.encodeNumberArray(ce(c,H(f)),r),"SPECK32_64ECB (insecure)":(c,r,f)=>w.encodeNumberArray(le(c,L(f)),r)},YES:{PLAIN:(c,r)=>w.decodeToString(c,r),SPECK48_96CTR:(c,r,f)=>se(w.decodeToNumberArray(c,r),H(f)),"SPECK32_64ECB (insecure)":(c,r,f)=>ue(w.decodeToNumberArray(c,r),L(f))}}; +(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/chrome/manifest.json b/dist/chrome/manifest.json index 1862f26..f002b2e 100644 --- a/dist/chrome/manifest.json +++ b/dist/chrome/manifest.json @@ -1 +1 @@ -{"name":"inØsight","version":"2.2.1","author":"planetrenox@pm.me","homepage_url":"https://github.com/planetrenox/inzerosight","description":"Communicate undetected in plain sight.","icons":{"48":"icon_500.png"},"manifest_version":3,"action":{"default_icon":{"48":"icon_500.png"},"default_title":"inØsight","default_popup":"index.html"}} \ No newline at end of file +{"name":"inØsight","version":"2.2.1","author":"planetrenox@pm.me","homepage_url":"https://github.com/planetrenox/inzerosight","description":"Communicate undetected in plain sight.","icons":{"48":"icon_500.png"},"manifest_version":3,"action":{"default_icon":{"48":"icon_500.png"},"default_title":"inØsight","default_popup":"index.html"},"content_scripts":[{"matches":[""],"js":["content.js"],"run_at":"document_idle"}]} \ No newline at end of file diff --git a/dist/firefox/content.js b/dist/firefox/content.js new file mode 100644 index 0000000..869442e --- /dev/null +++ b/dist/firefox/content.js @@ -0,0 +1,54 @@ +(function(){"use strict";const y={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:(o,e=3)=>Array.from(o,l=>l.codePointAt(0).toString(e).split("").map(b=>y[e][b]).join("")).join(y[e].unifier),encodeNumberArray:(o,e=3)=>o.map(l=>l.toString(e).split("").map(b=>y[e][b]).join("")).join(y[e].unifier),decodeToString:(o,e=3)=>o.split(y[e].unifier).map(l=>String.fromCodePoint(parseInt(Array.from(l).map(b=>Object.keys(y[e]).find(d=>y[e][d]===b)).join(""),e))).join(""),decodeToNumberArray:(o,e=3)=>o.split(y[e].unifier).map(l=>parseInt(Array.from(l).map(b=>Object.keys(y[e]).find(d=>y[e][d]===b)).join(""),e))};function V(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var D,P;function Y(){if(P)return D;P=1;function o(e={}){const l=e.bits||16,b=e.rounds||22,d=e.rightRotations||7,p=e.leftRotations||2,c=2**l,s=c-1,i=(a,n)=>a>>n|a<a<>l-n,m=(a,n,t)=>(a=i(a,d),a=a+n&s,a^=t,n=h(n,p),n^=a,[a,n]),E=(a,n,t)=>(n^=a,n=i(n,p),a^=t,a=a-n&s,a=h(a,d),[a,n]);function I(a,n){let t=a[0],u=a[1],r=n[0],g=n.slice(1);[u,t]=m(u,t,r);for(let w=0;w{const u=a([n/c|0,n&s],t);return u[0]*c+u[1]}}return{encrypt:f(I),decrypt:f(A),encryptRaw:I,decryptRaw:A}}return D=o,D}var J=Y();const v=V(J);var U,H;function L(){if(H)return U;H=1;const o="Input must be an string, Buffer or Uint8Array";function e(c){let s;if(c instanceof Uint8Array)s=c;else if(typeof c=="string")s=new TextEncoder().encode(c);else throw new Error(o);return s}function l(c){return Array.prototype.map.call(c,function(s){return(s<16?"0":"")+s.toString(16)}).join("")}function b(c){return(4294967296+c).toString(16).substring(1)}function d(c,s,i){let h=` +`+c+" = ";for(let m=0;m=4294967296&&w++,t[u]=g,t[u+1]=w}function l(t,u,r,g){let w=t[u]+r;r<0&&(w+=4294967296);let k=t[u+1]+g;w>=4294967296&&k++,t[u]=w,t[u+1]=k}function b(t,u){return t[u]^t[u+1]<<8^t[u+2]<<16^t[u+3]<<24}function d(t,u,r,g,w,k){const de=h[w],pe=h[w+1],be=h[k],he=h[k+1];e(i,t,u),l(i,t,de,pe);let S=i[g]^i[t],T=i[g+1]^i[t+1];i[g]=T,i[g+1]=S,e(i,r,g),S=i[u]^i[r],T=i[u+1]^i[r+1],i[u]=S>>>24^T<<8,i[u+1]=T>>>24^S<<8,e(i,t,u),l(i,t,be,he),S=i[g]^i[t],T=i[g+1]^i[t+1],i[g]=S>>>16^T<<16,i[g+1]=T>>>16^S<<16,e(i,r,g),S=i[u]^i[r],T=i[u+1]^i[r+1],i[u]=T>>>31^S<<1,i[u+1]=S>>>31^T<<1}const p=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=[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],s=new Uint8Array(c.map(function(t){return t*2})),i=new Uint32Array(32),h=new Uint32Array(32);function m(t,u){let r=0;for(r=0;r<16;r++)i[r]=t.h[r],i[r+16]=p[r];for(i[24]=i[24]^t.t,i[25]=i[25]^t.t/4294967296,u&&(i[28]=~i[28],i[29]=~i[29]),r=0;r<32;r++)h[r]=b(t.b,4*r);for(r=0;r<12;r++)d(0,8,16,24,s[r*16+0],s[r*16+1]),d(2,10,18,26,s[r*16+2],s[r*16+3]),d(4,12,20,28,s[r*16+4],s[r*16+5]),d(6,14,22,30,s[r*16+6],s[r*16+7]),d(0,10,20,30,s[r*16+8],s[r*16+9]),d(2,12,22,24,s[r*16+10],s[r*16+11]),d(4,14,16,26,s[r*16+12],s[r*16+13]),d(6,8,18,28,s[r*16+14],s[r*16+15]);for(r=0;r<16;r++)t.h[r]=t.h[r]^i[r]^i[r+16]}const E=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 I(t,u,r,g){if(t===0||t>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 w={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t};E.fill(0),E[0]=t,u&&(E[1]=u.length),E[2]=1,E[3]=1,r&&E.set(r,32),g&&E.set(g,48);for(let k=0;k<16;k++)w.h[k]=p[k]^b(E,k*4);return u&&(A(w,u),w.c=128),w}function A(t,u){for(let r=0;r>2]>>8*(r&3);return u}function a(t,u,r,g,w){r=r||64,t=o.normalizeInput(t),g&&(g=o.normalizeInput(g)),w&&(w=o.normalizeInput(w));const k=I(r,u,g,w);return A(k,t),f(k)}function n(t,u,r,g,w){const k=a(t,u,r,g,w);return o.toHex(k)}return B={blake2b:a,blake2bHex:n,blake2bInit:I,blake2bUpdate:A,blake2bFinal:f},B}var N,z;function Z(){if(z)return N;z=1;const o=L();function e(f,a){return f[a]^f[a+1]<<8^f[a+2]<<16^f[a+3]<<24}function l(f,a,n,t,u,r){c[f]=c[f]+c[a]+u,c[t]=b(c[t]^c[f],16),c[n]=c[n]+c[t],c[a]=b(c[a]^c[n],12),c[f]=c[f]+c[a]+r,c[t]=b(c[t]^c[f],8),c[n]=c[n]+c[t],c[a]=b(c[a]^c[n],7)}function b(f,a){return f>>>a^f<<32-a}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]),c=new Uint32Array(16),s=new Uint32Array(16);function i(f,a){let n=0;for(n=0;n<8;n++)c[n]=f.h[n],c[n+8]=d[n];for(c[12]^=f.t,c[13]^=f.t/4294967296,a&&(c[14]=~c[14]),n=0;n<16;n++)s[n]=e(f.b,4*n);for(n=0;n<10;n++)l(0,4,8,12,s[p[n*16+0]],s[p[n*16+1]]),l(1,5,9,13,s[p[n*16+2]],s[p[n*16+3]]),l(2,6,10,14,s[p[n*16+4]],s[p[n*16+5]]),l(3,7,11,15,s[p[n*16+6]],s[p[n*16+7]]),l(0,5,10,15,s[p[n*16+8]],s[p[n*16+9]]),l(1,6,11,12,s[p[n*16+10]],s[p[n*16+11]]),l(2,7,8,13,s[p[n*16+12]],s[p[n*16+13]]),l(3,4,9,14,s[p[n*16+14]],s[p[n*16+15]]);for(n=0;n<8;n++)f.h[n]^=c[n]^c[n+8]}function h(f,a){if(!(f>0&&f<=32))throw new Error("Incorrect output length, should be in [1, 32]");const n=a?a.length:0;if(a&&!(n>0&&n<=32))throw new Error("Incorrect key length, should be in [1, 32]");const t={h:new Uint32Array(d),b:new Uint8Array(64),c:0,t:0,outlen:f};return t.h[0]^=16842752^n<<8^f,n>0&&(m(t,a),t.c=64),t}function m(f,a){for(let n=0;n>2]>>8*(n&3)&255;return a}function I(f,a,n){n=n||32,f=o.normalizeInput(f);const t=h(n,a);return m(t,f),E(t)}function A(f,a,n){const t=I(f,a,n);return o.toHex(t)}return N={blake2s:I,blake2sHex:A,blake2sInit:h,blake2sUpdate:m,blake2sFinal:E},N}var _,G;function ee(){if(G)return _;G=1;const o=Q(),e=Z();return _={blake2b:o.blake2b,blake2bHex:o.blake2bHex,blake2bInit:o.blake2bInit,blake2bUpdate:o.blake2bUpdate,blake2bFinal:o.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},_}var q=ee();const te=v({bits:24,rounds:23,rightRotations:8,leftRotations:3});function ne(o){const e=q.blake2bHex(o,null,12);return[parseInt(e.slice(0,6),16),parseInt(e.slice(6,12),16),parseInt(e.slice(12,18),16),parseInt(e.slice(18,24),16)]}function re(o,e){if(!o||o.length===0)return"";const l=o[0];return o.slice(1).map((d,p)=>{const c=l*16777216+(p&16777215),s=te.encrypt(c,e),i=(d^s)>>>0;try{return String.fromCodePoint(i)}catch{return""}}).join("")}const oe=v();function ie(o){const e=q.blake2bHex(o,null,8);return[parseInt(e.slice(0,4),16),parseInt(e.slice(4,8),16),parseInt(e.slice(8,12),16),parseInt(e.slice(12,16),16)]}function se(o,e){return o.map(l=>{try{return String.fromCodePoint(oe.decrypt(l,e))}catch{return""}}).join("")}const K="‍​­",C={3:"‍​­᠎‍",6:"‍​­‌‍",8:"‍​­‌‌"},X={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(X).map(([o,e])=>[e,+o]));function ce(o){if(!o.includes(K))return null;const e=Object.keys(C).find(p=>o.includes(C[p]));if(!e)return null;const l=o.indexOf(C[e]),b=o.slice(l+C[e].length),d=y[e].unifier+y[e][0];if(b.startsWith(d)){const c=Array.from(b.slice(d.length,d.length+3)).map(m=>Object.keys(y[e]).find(E=>y[e][E]===m)).join(""),s=X[parseInt(c,e)],i=b.slice(d.length+3),h=C[e].length+d.length+3;return{base:e,cipher:s,payload:i,sigIdx:l,sigLen:h}}return{base:e,cipher:"PLAIN",payload:b,sigIdx:l,sigLen:C[e].length}}function ae(o,e,l){const b=new Set(Object.values(y[e]));let d=l;for(;dfe(i,e),F(i)}function F(o){const{wrap:e,node:l,start:b,end:d}=o;if(!l.isConnected){e.remove(),x.delete(o);return}const p=document.createRange();try{p.setStart(l,b),p.setEnd(l,Math.min(d,l.nodeValue.length))}catch{e.remove(),x.delete(o);return}let c=p.getBoundingClientRect();!c.width&&!c.height&&l.parentElement&&(c=l.parentElement.getBoundingClientRect());const s=c.left+window.scrollX+(c.width||0)/2,i=c.top+window.scrollY;e.style.left=`${s-e.offsetWidth/2}px`,e.style.top=`${i-e.offsetHeight-2}px`}function fe(o,e){const{wrap:l,node:b,start:d,end:p}=o,c=b.nodeValue.slice(d+e.sigLen,p);let s="";if(e.cipher==="PLAIN")try{s=y.decodeToString(c,e.base)}catch(i){console.error(i)}else{const i=prompt(`inØsight: enter password (${e.cipher}):`);if(!i)return;try{const h=y.decodeToNumberArray(c,e.base);e.cipher==="SPECK48_96CTR"?s=re(h,ne(i)):e.cipher==="SPECK32_64ECB (insecure)"&&(s=se(h,ie(i)))}catch(h){console.error(h)}if(!s){alert("Decryption failed.");return}}if(s){const i=document.createRange();i.setStart(b,d),i.setEnd(b,p),i.deleteContents();const h=document.createElement("span");h.className="inzerosight-decoded",h.style.color="#00b4d8",h.style.fontWeight="600",h.textContent=` ${s} `,i.insertNode(h),l.remove(),x.delete(o)}}const W=new WeakSet;function O(o){if(!o||o.nodeType!==Node.TEXT_NODE||W.has(o))return;const e=o.nodeValue;if(!e||!e.includes(K))return;W.add(o);let l=0;for(;l{var p;return e[(p=d.parentElement)==null?void 0:p.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let b;for(;b=l.nextNode();)O(b)}$(document.body),new MutationObserver(o=>{for(const e of o)if(e.type==="characterData")O(e.target);else for(const l of e.addedNodes)l.nodeType===Node.TEXT_NODE?O(l):l.nodeType===Node.ELEMENT_NODE&&l.id!=="in0-host"&&$(l)}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",()=>x.forEach(F),{passive:!0}),window.addEventListener("resize",()=>x.forEach(F),{passive:!0})})(); diff --git a/dist/firefox/index.css b/dist/firefox/index.css index 7eadd47..9804f44 100644 --- a/dist/firefox/index.css +++ b/dist/firefox/index.css @@ -1 +1 @@ -@font-face{font-family:Open Sans;font-style:normal;font-weight:400;font-display:swap;src:url(/open-sans-v44-latin-regular.woff2) format("woff2")}html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{font-family:Open Sans,sans-serif;background-color:#002b4d;width:500px;height:320px;line-height:1;border:1.5px solid rgb(0,126,199)}#overbar{position:relative;padding:1.5%;font-size:10px;font-weight:700;margin-bottom:0;color:#e5f4ff99;border-bottom:1px solid rgb(0,126,199,.5)}#sigDetect{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font-weight:400;color:#e5f4ffd9;opacity:0;transition:opacity 1s}#sigDetect.show{opacity:1;transition:none}#homepage{position:fixed;text-decoration:none;color:#ff0;right:2.5%}#textarea{background-color:#e6e6e6;margin:1.5%;width:95.5%;height:69%;font-family:Open Sans,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;line-height:20px}input{font-size:11.5px}#encodeButton{display:inline-block;margin-bottom:0;margin-left:1.5%;color:#002b4d;cursor:pointer}#decodeButton{margin-bottom:0;margin-left:1.5%;color:#002b4d;cursor:pointer}select{display:inline-block;margin-bottom:0;margin-left:1.5%;color:#002b4d;background-color:#e6e6e6;text-align:center;font-size:11px;width:8em;vertical-align:middle}#encodeButton,#decodeButton{vertical-align:middle}#sign{margin-left:1.5%;font-size:11px;padding:1px 8px;border-radius:99px;border:1px solid rgba(229,244,255,.2);background:transparent;color:#e5f4ff59;cursor:pointer;vertical-align:middle}#sign:hover{border-color:#e5f4ff59;color:#e5f4ff80}#sign.on{background:#e6e6e6;border-color:#e6e6e6;color:#002b4d}#sign.on:hover{background:#fff;border-color:#fff}#notice{font-size:10px;margin-top:1.5%;padding:.8% 0% 0% 1.7%;color:#e5f4ff99;border-top:1px solid rgb(0,126,199,.5)}#versions{color:#007ec7;text-decoration:none} +@font-face{font-family:Open Sans;font-style:normal;font-weight:400;font-display:swap;src:url(/open-sans-v44-latin-regular.woff2) format("woff2")}html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{font-family:Open Sans,sans-serif;background-color:#002b4d;width:500px;height:320px;line-height:1;border:1.5px solid rgb(0,126,199)}#overbar{position:relative;padding:1.5%;font-size:10px;font-weight:700;margin-bottom:0;color:#e5f4ff99;border-bottom:1px solid rgb(0,126,199,.5)}#sigDetect{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font-weight:400;color:#e5f4ffd9;opacity:0;transition:opacity 1s}#sigDetect.show{opacity:1;transition:opacity .2s}#homepage{position:fixed;text-decoration:none;color:#ff0;right:2.5%}#textarea{background-color:#e6e6e6;margin:1.5%;width:95.5%;height:69%;font-family:Open Sans,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;line-height:20px}input{font-size:11.5px}#encodeButton{display:inline-block;margin-bottom:0;margin-left:1.5%;color:#002b4d;cursor:pointer}#decodeButton{margin-bottom:0;margin-left:1.5%;color:#002b4d;cursor:pointer}select{display:inline-block;margin-bottom:0;margin-left:1.5%;color:#002b4d;background-color:#e6e6e6;text-align:center;font-size:11px;width:8em;vertical-align:middle}#encodeButton,#decodeButton{vertical-align:middle}#sign{margin-left:1.5%;font-size:11px;padding:1px 8px;border-radius:99px;border:1px solid rgba(229,244,255,.2);background:transparent;color:#e5f4ff59;cursor:pointer;vertical-align:middle}#sign:hover{border-color:#e5f4ff59;color:#e5f4ff80}#sign.on{background:#e6e6e6;border-color:#e6e6e6;color:#002b4d}#sign.on:hover{background:#fff;border-color:#fff}#notice{font-size:10px;margin-top:1.5%;padding:.8% 0% 0% 1.7%;color:#e5f4ff99;border-top:1px solid rgb(0,126,199,.5)}#versions{color:#007ec7;text-decoration:none} diff --git a/dist/firefox/index.js b/dist/firefox/index.js index 001cd0b..53fd572 100644 --- a/dist/firefox/index.js +++ b/dist/firefox/index.js @@ -1,4 +1,4 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))p(d);new MutationObserver(d=>{for(const b of d)if(b.type==="childList")for(const s of b.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&p(s)}).observe(document,{childList:!0,subtree:!0});function f(d){const b={};return d.integrity&&(b.integrity=d.integrity),d.referrerPolicy&&(b.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?b.credentials="include":d.crossOrigin==="anonymous"?b.credentials="omit":b.credentials="same-origin",b}function p(d){if(d.ep)return;d.ep=!0;const b=f(d);fetch(d.href,b)}})();const w={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:(c,r=3)=>Array.from(c,f=>f.codePointAt(0).toString(r).split("").map(p=>w[r][p]).join("")).join(w[r].unifier),encodeNumberArray:(c,r=3)=>c.map(f=>f.toString(r).split("").map(p=>w[r][p]).join("")).join(w[r].unifier),decodeToString:(c,r=3)=>c.split(w[r].unifier).map(f=>String.fromCodePoint(parseInt(Array.from(f).map(p=>Object.keys(w[r]).find(d=>w[r][d]===p)).join(""),r))).join(""),decodeToNumberArray:(c,r=3)=>c.split(w[r].unifier).map(f=>parseInt(Array.from(f).map(p=>Object.keys(w[r]).find(d=>w[r][d]===p)).join(""),r))};function ee(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}var T,_;function te(){if(_)return T;_=1;function c(r={}){const f=r.bits||16,p=r.rounds||22,d=r.rightRotations||7,b=r.leftRotations||2,s=2**f,o=s-1,l=(i,t)=>i>>t|i<i<>f-t,k=(i,t,e)=>(i=l(i,d),i=i+t&o,i^=e,t=m(t,b),t^=i,[i,t]),A=(i,t,e)=>(t^=i,t=l(t,b),i^=e,i=i-t&o,i=m(i,d),[i,t]);function I(i,t){let e=i[0],u=i[1],n=t[0],g=t.slice(1);[u,e]=k(u,e,n);for(let h=0;h{const u=i([t/s|0,t&o],e);return u[0]*s+u[1]}}return{encrypt:a(I),decrypt:a(E),encryptRaw:I,decryptRaw:E}}return T=c,T}var ne=te();const G=ee(ne);var C,N;function K(){if(N)return C;N=1;const c="Input must be an string, Buffer or Uint8Array";function r(s){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=new TextEncoder().encode(s);else throw new Error(c);return o}function f(s){return Array.prototype.map.call(s,function(o){return(o<16?"0":"")+o.toString(16)}).join("")}function p(s){return(4294967296+s).toString(16).substring(1)}function d(s,o,l){let m=` -`+s+" = ";for(let k=0;k=4294967296&&h++,e[u]=g,e[u+1]=h}function f(e,u,n,g){let h=e[u]+n;n<0&&(h+=4294967296);let y=e[u+1]+g;h>=4294967296&&y++,e[u]=h,e[u+1]=y}function p(e,u){return e[u]^e[u+1]<<8^e[u+2]<<16^e[u+3]<<24}function d(e,u,n,g,h,y){const Z=m[h],X=m[h+1],J=m[y],Q=m[y+1];r(l,e,u),f(l,e,Z,X);let B=l[g]^l[e],S=l[g+1]^l[e+1];l[g]=S,l[g+1]=B,r(l,n,g),B=l[u]^l[n],S=l[u+1]^l[n+1],l[u]=B>>>24^S<<8,l[u+1]=S>>>24^B<<8,r(l,e,u),f(l,e,J,Q),B=l[g]^l[e],S=l[g+1]^l[e+1],l[g]=B>>>16^S<<16,l[g+1]=S>>>16^B<<16,r(l,n,g),B=l[u]^l[n],S=l[u+1]^l[n+1],l[u]=S>>>31^B<<1,l[u+1]=B>>>31^S<<1}const b=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 k(e,u){let n=0;for(n=0;n<16;n++)l[n]=e.h[n],l[n+16]=b[n];for(l[24]=l[24]^e.t,l[25]=l[25]^e.t/4294967296,u&&(l[28]=~l[28],l[29]=~l[29]),n=0;n<32;n++)m[n]=p(e.b,4*n);for(n=0;n<12;n++)d(0,8,16,24,o[n*16+0],o[n*16+1]),d(2,10,18,26,o[n*16+2],o[n*16+3]),d(4,12,20,28,o[n*16+4],o[n*16+5]),d(6,14,22,30,o[n*16+6],o[n*16+7]),d(0,10,20,30,o[n*16+8],o[n*16+9]),d(2,12,22,24,o[n*16+10],o[n*16+11]),d(4,14,16,26,o[n*16+12],o[n*16+13]),d(6,8,18,28,o[n*16+14],o[n*16+15]);for(n=0;n<16;n++)e.h[n]=e.h[n]^l[n]^l[n+16]}const A=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 I(e,u,n,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(n&&n.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};A.fill(0),A[0]=e,u&&(A[1]=u.length),A[2]=1,A[3]=1,n&&A.set(n,32),g&&A.set(g,48);for(let y=0;y<16;y++)h.h[y]=b[y]^p(A,y*4);return u&&(E(h,u),h.c=128),h}function E(e,u){for(let n=0;n>2]>>8*(n&3);return u}function i(e,u,n,g,h){n=n||64,e=c.normalizeInput(e),g&&(g=c.normalizeInput(g)),h&&(h=c.normalizeInput(h));const y=I(n,u,g,h);return E(y,e),a(y)}function t(e,u,n,g,h){const y=i(e,u,n,g,h);return c.toHex(y)}return D={blake2b:i,blake2bHex:t,blake2bInit:I,blake2bUpdate:E,blake2bFinal:a},D}var O,v;function oe(){if(v)return O;v=1;const c=K();function r(a,i){return a[i]^a[i+1]<<8^a[i+2]<<16^a[i+3]<<24}function f(a,i,t,e,u,n){s[a]=s[a]+s[i]+u,s[e]=p(s[e]^s[a],16),s[t]=s[t]+s[e],s[i]=p(s[i]^s[t],12),s[a]=s[a]+s[i]+n,s[e]=p(s[e]^s[a],8),s[t]=s[t]+s[e],s[i]=p(s[i]^s[t],7)}function p(a,i){return a>>>i^a<<32-i}const d=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),b=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(a,i){let t=0;for(t=0;t<8;t++)s[t]=a.h[t],s[t+8]=d[t];for(s[12]^=a.t,s[13]^=a.t/4294967296,i&&(s[14]=~s[14]),t=0;t<16;t++)o[t]=r(a.b,4*t);for(t=0;t<10;t++)f(0,4,8,12,o[b[t*16+0]],o[b[t*16+1]]),f(1,5,9,13,o[b[t*16+2]],o[b[t*16+3]]),f(2,6,10,14,o[b[t*16+4]],o[b[t*16+5]]),f(3,7,11,15,o[b[t*16+6]],o[b[t*16+7]]),f(0,5,10,15,o[b[t*16+8]],o[b[t*16+9]]),f(1,6,11,12,o[b[t*16+10]],o[b[t*16+11]]),f(2,7,8,13,o[b[t*16+12]],o[b[t*16+13]]),f(3,4,9,14,o[b[t*16+14]],o[b[t*16+15]]);for(t=0;t<8;t++)a.h[t]^=s[t]^s[t+8]}function m(a,i){if(!(a>0&&a<=32))throw new Error("Incorrect output length, should be in [1, 32]");const t=i?i.length:0;if(i&&!(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:a};return e.h[0]^=16842752^t<<8^a,t>0&&(k(e,i),e.c=64),e}function k(a,i){for(let t=0;t>2]>>8*(t&3)&255;return i}function I(a,i,t){t=t||32,a=c.normalizeInput(a);const e=m(t,i);return k(e,a),A(e)}function E(a,i,t){const e=I(a,i,t);return c.toHex(e)}return O={blake2s:I,blake2sHex:E,blake2sInit:m,blake2sUpdate:k,blake2sFinal:A},O}var j,x;function ie(){if(x)return j;x=1;const c=re(),r=oe();return j={blake2b:c.blake2b,blake2bHex:c.blake2bHex,blake2bInit:c.blake2bInit,blake2bUpdate:c.blake2bUpdate,blake2bFinal:c.blake2bFinal,blake2s:r.blake2s,blake2sHex:r.blake2sHex,blake2sInit:r.blake2sInit,blake2sUpdate:r.blake2sUpdate,blake2sFinal:r.blake2sFinal},j}var z=ie();const Y=G({bits:24,rounds:23,rightRotations:8,leftRotations:3});function H(c){const r=z.blake2bHex(c,null,12);return[parseInt(r.slice(0,6),16),parseInt(r.slice(6,12),16),parseInt(r.slice(12,18),16),parseInt(r.slice(18,24),16)]}function ce(c,r){const f=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]&16777215,p=Array.from(c,(d,b)=>{const s=f*16777216+(b&16777215),o=Y.encrypt(s,r);return(d.codePointAt(0)^o)>>>0});return[f,...p]}function se(c,r){if(!c||c.length===0)return"";const f=c[0];return c.slice(1).map((d,b)=>{const s=f*16777216+(b&16777215),o=Y.encrypt(s,r),l=(d^o)>>>0;try{return String.fromCodePoint(l)}catch{return""}}).join("")}const $=G();function L(c){const r=z.blake2bHex(c,null,8);return[parseInt(r.slice(0,4),16),parseInt(r.slice(4,8),16),parseInt(r.slice(8,12),16),parseInt(r.slice(12,16),16)]}function le(c,r){return Array.from(c,f=>$.encrypt(f.codePointAt(0),r))}function ue(c,r){return c.map(f=>{try{return String.fromCodePoint($.decrypt(f,r))}catch{return""}}).join("")}const U=document.getElementById("textarea"),M=document.getElementById("encoder"),ae=document.getElementById("cipher"),V=document.getElementById("sign"),F=document.getElementById("sigDetect"),R={3:"‍​­᠎",6:"‍​­⁠",8:"‍​­\uFEFF"};document.getElementById("encodeButton").addEventListener("click",W);document.getElementById("decodeButton").addEventListener("click",W);V.addEventListener("click",c=>c.target.classList.toggle("on"));let q;function W(c){if(clearTimeout(q),F.className="",U.value===""){U.value="The text box is empty.";return}const r=c.target.id==="encodeButton"?"NO":"YES",f=fe();let p=M.value.split("-")[1],d=U.value;if(r==="YES"){const o=Object.keys(R).find(l=>d.includes(R[l]));o&&(o!==p&&(F.textContent=`ZWUS-${o} signature detected`,F.className="show",q=setTimeout(()=>F.className="",2e3)),p=o,M.value="ZWUS-"+p,d=d.replace(R[p],""))}const b=f!=="PLAIN",s=b&&prompt("enter password.");if(!(b&&!s)){try{let o=de[r][f](d,p,s);r==="NO"&&V.classList.contains("on")&&(o=R[p]+o),U.value=o}catch(o){console.log(o)}r==="NO"&&(U.select(),document.execCommand("copy"),U.value=`Copied to your clipboard. - A copy has been placed between these brackets [`+U.value+"]")}}function fe(){return ae.value}const de={NO:{PLAIN:(c,r)=>w.encodeString(c,r),SPECK48_96CTR:(c,r,f)=>w.encodeNumberArray(ce(c,H(f)),r),"SPECK32_64ECB (insecure)":(c,r,f)=>w.encodeNumberArray(le(c,L(f)),r)},YES:{PLAIN:(c,r)=>w.decodeToString(c,r),SPECK48_96CTR:(c,r,f)=>se(w.decodeToNumberArray(c,r),H(f)),"SPECK32_64ECB (insecure)":(c,r,f)=>ue(w.decodeToNumberArray(c,r),L(f))}}; +(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/firefox/manifest.json b/dist/firefox/manifest.json index 633e5a5..54f43ca 100644 --- a/dist/firefox/manifest.json +++ b/dist/firefox/manifest.json @@ -1 +1 @@ -{"name":"inØsight","version":"2.2.1","author":"planetrenox@pm.me","homepage_url":"https://github.com/planetrenox/inzerosight","description":"Communicate undetected in plain sight.","icons":{"48":"icon_500.png"},"manifest_version":2,"browser_action":{"browser_style":false,"default_icon":"icon_500.png","default_title":"inØsight","default_popup":"index.html"},"content_security_policy":"script-src 'self'; style-src 'self';","browser_specific_settings":{"gecko":{"id":"{0a73f41c-c59c-404b-9e07-f7392fa830d4}"}}} \ No newline at end of file +{"name":"inØsight","version":"2.2.1","author":"planetrenox@pm.me","homepage_url":"https://github.com/planetrenox/inzerosight","description":"Communicate undetected in plain sight.","icons":{"48":"icon_500.png"},"manifest_version":2,"browser_action":{"browser_style":false,"default_icon":"icon_500.png","default_title":"inØsight","default_popup":"index.html"},"content_security_policy":"script-src 'self'; style-src 'self';","browser_specific_settings":{"gecko":{"id":"{0a73f41c-c59c-404b-9e07-f7392fa830d4}"}},"content_scripts":[{"matches":[""],"js":["content.js"],"run_at":"document_idle"}]} \ No newline at end of file diff --git a/dist/web/assets/index-CZZybJ_s.js b/dist/web/assets/index-CZZybJ_s.js deleted file mode 100644 index 001cd0b..0000000 --- a/dist/web/assets/index-CZZybJ_s.js +++ /dev/null @@ -1,4 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))p(d);new MutationObserver(d=>{for(const b of d)if(b.type==="childList")for(const s of b.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&p(s)}).observe(document,{childList:!0,subtree:!0});function f(d){const b={};return d.integrity&&(b.integrity=d.integrity),d.referrerPolicy&&(b.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?b.credentials="include":d.crossOrigin==="anonymous"?b.credentials="omit":b.credentials="same-origin",b}function p(d){if(d.ep)return;d.ep=!0;const b=f(d);fetch(d.href,b)}})();const w={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:(c,r=3)=>Array.from(c,f=>f.codePointAt(0).toString(r).split("").map(p=>w[r][p]).join("")).join(w[r].unifier),encodeNumberArray:(c,r=3)=>c.map(f=>f.toString(r).split("").map(p=>w[r][p]).join("")).join(w[r].unifier),decodeToString:(c,r=3)=>c.split(w[r].unifier).map(f=>String.fromCodePoint(parseInt(Array.from(f).map(p=>Object.keys(w[r]).find(d=>w[r][d]===p)).join(""),r))).join(""),decodeToNumberArray:(c,r=3)=>c.split(w[r].unifier).map(f=>parseInt(Array.from(f).map(p=>Object.keys(w[r]).find(d=>w[r][d]===p)).join(""),r))};function ee(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}var T,_;function te(){if(_)return T;_=1;function c(r={}){const f=r.bits||16,p=r.rounds||22,d=r.rightRotations||7,b=r.leftRotations||2,s=2**f,o=s-1,l=(i,t)=>i>>t|i<i<>f-t,k=(i,t,e)=>(i=l(i,d),i=i+t&o,i^=e,t=m(t,b),t^=i,[i,t]),A=(i,t,e)=>(t^=i,t=l(t,b),i^=e,i=i-t&o,i=m(i,d),[i,t]);function I(i,t){let e=i[0],u=i[1],n=t[0],g=t.slice(1);[u,e]=k(u,e,n);for(let h=0;h{const u=i([t/s|0,t&o],e);return u[0]*s+u[1]}}return{encrypt:a(I),decrypt:a(E),encryptRaw:I,decryptRaw:E}}return T=c,T}var ne=te();const G=ee(ne);var C,N;function K(){if(N)return C;N=1;const c="Input must be an string, Buffer or Uint8Array";function r(s){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=new TextEncoder().encode(s);else throw new Error(c);return o}function f(s){return Array.prototype.map.call(s,function(o){return(o<16?"0":"")+o.toString(16)}).join("")}function p(s){return(4294967296+s).toString(16).substring(1)}function d(s,o,l){let m=` -`+s+" = ";for(let k=0;k=4294967296&&h++,e[u]=g,e[u+1]=h}function f(e,u,n,g){let h=e[u]+n;n<0&&(h+=4294967296);let y=e[u+1]+g;h>=4294967296&&y++,e[u]=h,e[u+1]=y}function p(e,u){return e[u]^e[u+1]<<8^e[u+2]<<16^e[u+3]<<24}function d(e,u,n,g,h,y){const Z=m[h],X=m[h+1],J=m[y],Q=m[y+1];r(l,e,u),f(l,e,Z,X);let B=l[g]^l[e],S=l[g+1]^l[e+1];l[g]=S,l[g+1]=B,r(l,n,g),B=l[u]^l[n],S=l[u+1]^l[n+1],l[u]=B>>>24^S<<8,l[u+1]=S>>>24^B<<8,r(l,e,u),f(l,e,J,Q),B=l[g]^l[e],S=l[g+1]^l[e+1],l[g]=B>>>16^S<<16,l[g+1]=S>>>16^B<<16,r(l,n,g),B=l[u]^l[n],S=l[u+1]^l[n+1],l[u]=S>>>31^B<<1,l[u+1]=B>>>31^S<<1}const b=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 k(e,u){let n=0;for(n=0;n<16;n++)l[n]=e.h[n],l[n+16]=b[n];for(l[24]=l[24]^e.t,l[25]=l[25]^e.t/4294967296,u&&(l[28]=~l[28],l[29]=~l[29]),n=0;n<32;n++)m[n]=p(e.b,4*n);for(n=0;n<12;n++)d(0,8,16,24,o[n*16+0],o[n*16+1]),d(2,10,18,26,o[n*16+2],o[n*16+3]),d(4,12,20,28,o[n*16+4],o[n*16+5]),d(6,14,22,30,o[n*16+6],o[n*16+7]),d(0,10,20,30,o[n*16+8],o[n*16+9]),d(2,12,22,24,o[n*16+10],o[n*16+11]),d(4,14,16,26,o[n*16+12],o[n*16+13]),d(6,8,18,28,o[n*16+14],o[n*16+15]);for(n=0;n<16;n++)e.h[n]=e.h[n]^l[n]^l[n+16]}const A=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 I(e,u,n,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(n&&n.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};A.fill(0),A[0]=e,u&&(A[1]=u.length),A[2]=1,A[3]=1,n&&A.set(n,32),g&&A.set(g,48);for(let y=0;y<16;y++)h.h[y]=b[y]^p(A,y*4);return u&&(E(h,u),h.c=128),h}function E(e,u){for(let n=0;n>2]>>8*(n&3);return u}function i(e,u,n,g,h){n=n||64,e=c.normalizeInput(e),g&&(g=c.normalizeInput(g)),h&&(h=c.normalizeInput(h));const y=I(n,u,g,h);return E(y,e),a(y)}function t(e,u,n,g,h){const y=i(e,u,n,g,h);return c.toHex(y)}return D={blake2b:i,blake2bHex:t,blake2bInit:I,blake2bUpdate:E,blake2bFinal:a},D}var O,v;function oe(){if(v)return O;v=1;const c=K();function r(a,i){return a[i]^a[i+1]<<8^a[i+2]<<16^a[i+3]<<24}function f(a,i,t,e,u,n){s[a]=s[a]+s[i]+u,s[e]=p(s[e]^s[a],16),s[t]=s[t]+s[e],s[i]=p(s[i]^s[t],12),s[a]=s[a]+s[i]+n,s[e]=p(s[e]^s[a],8),s[t]=s[t]+s[e],s[i]=p(s[i]^s[t],7)}function p(a,i){return a>>>i^a<<32-i}const d=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),b=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(a,i){let t=0;for(t=0;t<8;t++)s[t]=a.h[t],s[t+8]=d[t];for(s[12]^=a.t,s[13]^=a.t/4294967296,i&&(s[14]=~s[14]),t=0;t<16;t++)o[t]=r(a.b,4*t);for(t=0;t<10;t++)f(0,4,8,12,o[b[t*16+0]],o[b[t*16+1]]),f(1,5,9,13,o[b[t*16+2]],o[b[t*16+3]]),f(2,6,10,14,o[b[t*16+4]],o[b[t*16+5]]),f(3,7,11,15,o[b[t*16+6]],o[b[t*16+7]]),f(0,5,10,15,o[b[t*16+8]],o[b[t*16+9]]),f(1,6,11,12,o[b[t*16+10]],o[b[t*16+11]]),f(2,7,8,13,o[b[t*16+12]],o[b[t*16+13]]),f(3,4,9,14,o[b[t*16+14]],o[b[t*16+15]]);for(t=0;t<8;t++)a.h[t]^=s[t]^s[t+8]}function m(a,i){if(!(a>0&&a<=32))throw new Error("Incorrect output length, should be in [1, 32]");const t=i?i.length:0;if(i&&!(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:a};return e.h[0]^=16842752^t<<8^a,t>0&&(k(e,i),e.c=64),e}function k(a,i){for(let t=0;t>2]>>8*(t&3)&255;return i}function I(a,i,t){t=t||32,a=c.normalizeInput(a);const e=m(t,i);return k(e,a),A(e)}function E(a,i,t){const e=I(a,i,t);return c.toHex(e)}return O={blake2s:I,blake2sHex:E,blake2sInit:m,blake2sUpdate:k,blake2sFinal:A},O}var j,x;function ie(){if(x)return j;x=1;const c=re(),r=oe();return j={blake2b:c.blake2b,blake2bHex:c.blake2bHex,blake2bInit:c.blake2bInit,blake2bUpdate:c.blake2bUpdate,blake2bFinal:c.blake2bFinal,blake2s:r.blake2s,blake2sHex:r.blake2sHex,blake2sInit:r.blake2sInit,blake2sUpdate:r.blake2sUpdate,blake2sFinal:r.blake2sFinal},j}var z=ie();const Y=G({bits:24,rounds:23,rightRotations:8,leftRotations:3});function H(c){const r=z.blake2bHex(c,null,12);return[parseInt(r.slice(0,6),16),parseInt(r.slice(6,12),16),parseInt(r.slice(12,18),16),parseInt(r.slice(18,24),16)]}function ce(c,r){const f=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]&16777215,p=Array.from(c,(d,b)=>{const s=f*16777216+(b&16777215),o=Y.encrypt(s,r);return(d.codePointAt(0)^o)>>>0});return[f,...p]}function se(c,r){if(!c||c.length===0)return"";const f=c[0];return c.slice(1).map((d,b)=>{const s=f*16777216+(b&16777215),o=Y.encrypt(s,r),l=(d^o)>>>0;try{return String.fromCodePoint(l)}catch{return""}}).join("")}const $=G();function L(c){const r=z.blake2bHex(c,null,8);return[parseInt(r.slice(0,4),16),parseInt(r.slice(4,8),16),parseInt(r.slice(8,12),16),parseInt(r.slice(12,16),16)]}function le(c,r){return Array.from(c,f=>$.encrypt(f.codePointAt(0),r))}function ue(c,r){return c.map(f=>{try{return String.fromCodePoint($.decrypt(f,r))}catch{return""}}).join("")}const U=document.getElementById("textarea"),M=document.getElementById("encoder"),ae=document.getElementById("cipher"),V=document.getElementById("sign"),F=document.getElementById("sigDetect"),R={3:"‍​­᠎",6:"‍​­⁠",8:"‍​­\uFEFF"};document.getElementById("encodeButton").addEventListener("click",W);document.getElementById("decodeButton").addEventListener("click",W);V.addEventListener("click",c=>c.target.classList.toggle("on"));let q;function W(c){if(clearTimeout(q),F.className="",U.value===""){U.value="The text box is empty.";return}const r=c.target.id==="encodeButton"?"NO":"YES",f=fe();let p=M.value.split("-")[1],d=U.value;if(r==="YES"){const o=Object.keys(R).find(l=>d.includes(R[l]));o&&(o!==p&&(F.textContent=`ZWUS-${o} signature detected`,F.className="show",q=setTimeout(()=>F.className="",2e3)),p=o,M.value="ZWUS-"+p,d=d.replace(R[p],""))}const b=f!=="PLAIN",s=b&&prompt("enter password.");if(!(b&&!s)){try{let o=de[r][f](d,p,s);r==="NO"&&V.classList.contains("on")&&(o=R[p]+o),U.value=o}catch(o){console.log(o)}r==="NO"&&(U.select(),document.execCommand("copy"),U.value=`Copied to your clipboard. - A copy has been placed between these brackets [`+U.value+"]")}}function fe(){return ae.value}const de={NO:{PLAIN:(c,r)=>w.encodeString(c,r),SPECK48_96CTR:(c,r,f)=>w.encodeNumberArray(ce(c,H(f)),r),"SPECK32_64ECB (insecure)":(c,r,f)=>w.encodeNumberArray(le(c,L(f)),r)},YES:{PLAIN:(c,r)=>w.decodeToString(c,r),SPECK48_96CTR:(c,r,f)=>se(w.decodeToNumberArray(c,r),H(f)),"SPECK32_64ECB (insecure)":(c,r,f)=>ue(w.decodeToNumberArray(c,r),L(f))}}; diff --git a/dist/web/assets/index-wRI3Wnct.js b/dist/web/assets/index-wRI3Wnct.js new file mode 100644 index 0000000..53fd572 --- /dev/null +++ b/dist/web/assets/index-wRI3Wnct.js @@ -0,0 +1,4 @@ +(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 25395c6..de7cff3 100644 --- a/dist/web/index.html +++ b/dist/web/index.html @@ -1,33 +1,33 @@ - - - - - - + + + + + + - - -

inØsight 2.2.1source

- - - - - - -

- notice: some platforms restrict Ø width characters. -

- - + + +

inØsight 2.2.1source

+ + + + + + +

+ notice: some platforms restrict Ø width characters. +

+ + diff --git a/sig.js b/sig.js new file mode 100644 index 0000000..1f1ae5d --- /dev/null +++ b/sig.js @@ -0,0 +1,53 @@ +import zwus from 'zwus'; + +export const SIG_PREFIX = '\u{200D}\u{200B}\u{00AD}'; + +export const SIG = { + 3: '\u{200D}\u{200B}\u{00AD}\u{180E}\u{200D}', + 6: '\u{200D}\u{200B}\u{00AD}\u{200C}\u{200D}', + 8: '\u{200D}\u{200B}\u{00AD}\u{200C}\u{200C}' +}; + +export const CIPHERS = { + 1: 'SPECK48_96CTR', + 2: 'SPECK32_64ECB (insecure)' +}; + +export const CIPHER_TO_ID = Object.fromEntries( + Object.entries(CIPHERS).map(([k, v]) => [v, +k]) +); + +export function makeSig(base, cipher) { + let s = SIG[base]; + const id = CIPHER_TO_ID[cipher]; + if (id) { + const zwDigits = Array.from(id.toString(base).padStart(3, '0'), d => zwus[base][d]).join(''); + s += zwus[base].unifier + zwus[base][0] + zwDigits; + } + return s; +} + +export function parseSig(text) { + if (!text.includes(SIG_PREFIX)) return null; + const base = Object.keys(SIG).find(b => text.includes(SIG[b])); + if (!base) return null; + const sigIdx = text.indexOf(SIG[base]); + const after = text.slice(sigIdx + SIG[base].length); + const barrier = zwus[base].unifier + zwus[base][0]; + if (after.startsWith(barrier)) { + const zwDigits = Array.from(after.slice(barrier.length, barrier.length + 3)); + const digits = zwDigits.map(z => Object.keys(zwus[base]).find(k => zwus[base][k] === z)).join(''); + const cipher = CIPHERS[parseInt(digits, base)]; + const payload = after.slice(barrier.length + 3); + const sigLen = SIG[base].length + barrier.length + 3; + return { base, cipher, payload, sigIdx, sigLen }; + } + return { base, cipher: 'PLAIN', payload: after, sigIdx, sigLen: SIG[base].length }; +} + +export function getPayloadEnd(text, base, startOffset) { + const zw = new Set(Object.values(zwus[base])); + let i = startOffset; + while (i < text.length && zw.has(text[i])) i++; + return i; +} diff --git a/vite.config.js b/vite.config.js index 692e36d..41963f2 100644 --- a/vite.config.js +++ b/vite.config.js @@ -19,6 +19,12 @@ export default defineConfig(async ({ mode }) => { icons: { "48": "icon_500.png" }, }; + const content_scripts = [{ + matches: [""], + js: ["content.js"], + run_at: "document_idle" + }]; + if (target === 'chrome') { return { ...base, @@ -28,6 +34,7 @@ export default defineConfig(async ({ mode }) => { default_title: "in\u00D8sight", default_popup: "index.html", }, + content_scripts, }; } @@ -46,6 +53,7 @@ export default defineConfig(async ({ mode }) => { id: "{0a73f41c-c59c-404b-9e07-f7392fa830d4}", }, }, + content_scripts, }; }, })