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+NjE4ODI3MvwK3V8jj6jIwy1p4sdwVpbmYJPlcoc0HHyN8QB7eWFD6R+9OpxQDiv+LAt8SlWfCz" +
"D2Yx6HR89XwLTOKSQoAQqsPXZugl9gfVK9ob7nxXSNL7ZoyMzS3rVAlxkDLU/B8TfJOHfyTAiYWrI0" +
"rP2hqTE4ZF6fGSmTclhSrrFIhcBMxEVopyBTe661DXfXC5v7OBsfOiReAYpQiXChB4xbKa/vF1pWtC" +
"h+wHZwvOrTXyGumD4EpGfIu/RIHVGd2EBKcbTxLU9DCUxFWKwOg8BAxJVSirJnk53PcZ0GpbVUIO0a" +...