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+NjE4ODI3MvRu3UPjDiTJ154O44d7kqAeAVCsuh1RHoxT23ckTSNfggmeA7y+FSBTKFI2aIukTl" +
"enXi1bp10xNt5qFv+Y7Ta/FD82hkHI8NBBUaaf782LAr7ykk1GCIcI+LBu+0sQQsQxKgMJNqmeUDrz" +
"MWgs+53Pzsju2aqobQH0SK6os2FbBbIslvo92dYeZiAbLZ7wN58VGVKdjevNE7mzkmrA2Bw2rmuu9R" +
"RxIe15eCqXOQQSjg4Zrgp0HyKTMS4edMT7Tcb18TBOnbwEq0CKpfK188GA6q0qjVD117wHupJ/raDV" +...