- RC4 - NodeJs ```jsx const rc4 = require("arc4"); const fs=require('fs') const data=fs.readFileSync('stacer.jpeg') const uData=new Uint8Array(data) const key = "123456789123456789"; // const data = e.target.result; const fSize = data.byteLength; const cipher = rc4("arc4", key); // const enc = cipher.encodeBuffer(uData); const enc = cipher.encodeArray(uData); console.log("🚀 ~ file: script.js:76 ~ fr.addEventListener ~ enc:", enc); // const dec = cipher.decodeBuffer(enc); const dec = cipher.decodeArray(enc); console.log("🚀 ~ file: script.js:78 ~ fr.addEventListener ~ dec:", dec); const decBuffer=Buffer.from(dec) fs.writeFileSync('stacerdec.jpeg',decBuffer) ``` - Javascript(Client side) ```jsx // Function to read a file and return its content as a promise function readFile(fileInput) { return new Promise((resolve, reject) => { const file = fileInput.files[0]; if (!file) { reject("No file selected"); return; } const reader = new FileReader(); reader.onload = (event) => { resolve(event.target.result); }; reader.readAsArrayBuffer(file); }); } // Function to save encrypted data to a file function saveEncryptedFile(encryptedData) { const blob = new Blob([encryptedData]); const a = document.createElement("a"); a.href = URL.createObjectURL(blob); a.download = "encrypted_file.enc"; a.click(); } // Function to save decrypted data to a file function saveDecryptedFile(decryptedData) { const blob = new Blob([decryptedData]); const a = document.createElement("a"); a.href = URL.createObjectURL(blob); a.download = "decrypted_file.txt"; // Change the file extension as needed a.click(); } // Function to encrypt a file using ARC4 async function encryptFile() { const fileInput = document.getElementById("fileInput"); const fileContent = await readFile(fileInput); const rc4 = ARC4("your_secret_key"); const encryptedData = rc4.encrypt(new Uint8Array(fileContent)); saveEncryptedFile(encryptedData); } // Function to decrypt an encrypted file using ARC4 async function decryptFile() { const encryptedFileInput = document.getElementById("encryptedFileInput"); const encryptedContent = await readFile(encryptedFileInput); const rc4 = ARC4("your_secret_key"); const decryptedData = rc4.decrypt(new Uint8Array(encryptedContent)); saveDecryptedFile(decryptedData); } ``` - AES ```jsx // merging splitted Uint8arrays to single one const mergeTo1D=(uarrays)=>{ if(uarrays.length===0) { return [] } const sum=0 for(let urray of urray) { sum+=urray/length } const mergedArray= new Uint8Array(sum) mergedArray.set(uarrays[0],0) for(let i=1;i console.error("Input Stream Error:", err)); outputStream.on("error", (err) => console.error("Output Stream Error:", err)); outputStream.on("finish", () => console.log("Encryption completed.")); // Optionally, you can handle stream close events as well inputStream.on("close", () => console.log("Input stream closed.")); outputStream.on("close", () => console.log("Output stream closed.")); ```   decryption.js ```jsx const fs = require("fs"); const crypto = require("crypto"); const CryptoJS = require("crypto-js"); require("crypto-js/aes"); // const fileName='Joplin-2.12.18.AppImage' // const fileName='stacer.jpeg' const fileName='Black.Mirror.S06E01.Joan.Is.Awful.720p.10Bit.Hindi.English.Esubs.MoviesMod.org.mkv' // Input and output file paths const inputFile = `${fileName}.enc`; // Replace with your output file path const outputFile = `${fileName}.dec`; // Replace with your output file path const key=fs.readFileSync('key.bin'); const iv=fs.readFileSync('iv.bin'); const inputStream = fs.createReadStream(inputFile); const outputStream = fs.createWriteStream(outputFile); // Decrypt and write the file in chunks const decryptionStream = crypto.createDecipheriv("aes-256-cbc", Buffer.from(key), iv); inputStream.pipe(decryptionStream).pipe(outputStream); // Handle events and errors inputStream.on("error", (err) => console.error("Input Stream Error:", err)); outputStream.on("error", (err) => console.error("Output Stream Error:", err)); outputStream.on("finish", () => console.log("Decryption completed.")); // Optionally, you can handle stream close events as well inputStream.on("close", () => console.log("Input stream closed.")); outputStream.on("close", () => console.log("Output stream closed.")); ``` - client side javascript(browser)   encryption.html ```jsx Large File Encryption ```   decryption.js ```jsx File Decryption

File Decryption

```