JSFiddle - React, Tailwind, and code Playground

by dledle2

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Decrypted Page</title>
</head>
<body>
  <script>
    function customHash(str, rounds) {
      let h = [...str].reduce((sum, ch) => sum + ch.charCodeAt(0), 0);
      for (let i = 0; i < rounds; i++) {
        h = ((h << 5) - h) + (h >>> 2) + i;
        h ^= (h << 7) | (h >>> 3);
        h = Math.abs(h);
      }
      return h;
    }

    // XOR-decrypt + gunzip
    async function decryptAndDecompress(encData, key) {
      const rawStr    = atob(encData); // atob will handle the concatenated string fine
      const rawBytes  = Uint8Array.from(rawStr, c => c.charCodeAt(0));
      const keyBytes  = new TextEncoder().encode(key);
      const decBytes  = new Uint8Array(rawBytes.length);
      for (let i = 0; i < rawBytes.length; i++) {
        decBytes[i] = rawBytes[i] ^ keyBytes[i % keyBytes.length];
      }
      const blob   = new Blob([decBytes]);
      const ds     = blob.stream().pipeThrough(new DecompressionStream('gzip'));
      const reader = ds.getReader();
      const chunks = [];
      while (true) {
        const { done, value } = await reader.read();
        if (done) break;
        chunks.push(value);
      }
      return new Blob(chunks).text();
    }

    document.addEventListener('DOMContentLoaded', async () => {
      try {
        const pwd = prompt('Enter password:');
        if (!pwd) return;
        const key = customHash(pwd, 100000).toString();
        // MODIFIED PART: Use the chunked data.
        // The chunkedEncData variable already contains quotes and + signs.
        const html = await decryptAndDecompress("J7I+NjE4ODI3MlxMcYPVYKDrhG/HrqLCUZp9sLI91kdfLjuajf86bFo1Yn2OOBenHZDFpxeMfv4mJ9" + 
          "8wt1EHIEnK4c750IYkItVhg8TlZ8zH087Tnbq/yoWoytiR2bAE9szFv5aZacpEs43lEmfgSsrVH+XW" + 
          "xnXKwhKJ7Wmgx7z/5dSmjg7MCtsEyct+FdHh7WbC7n5zhpxOzsqZ1t6tR8oixKTC4VX01i0jU4Pi5c" + 
          "eN5WHJ43bLrtxlxrHM0zIyiaUJ9oxJn8KFeevSbw9LFcIG0vq3skYr7tQdz6AProOY78XdgZ6Cp/RS" +...