const crypto = require('crypto'); const fs = require('fs'); const path = require('path'); const algorithm = 'aes-256-ctr'; const password = 'skyfffire-password'; const key = crypto.createHash('sha256').update(password).digest(); const iv = crypto.randomBytes(16); function encryptFile(filePath) { console.log(`Encrypting: ${filePath}`); const fileContent = fs.readFileSync(filePath); const cipher = crypto.createCipheriv(algorithm, key, iv); const encrypted = Buffer.concat([cipher.update(fileContent), cipher.final()]); fs.writeFileSync(filePath, Buffer.concat([iv, encrypted])); // Store IV with encrypted data console.log(`Encrypted: ${filePath}`); } function encryptDirectory(directoryPath) { const files = fs.readdirSync(directoryPath); files.forEach(file => { const fullPath = path.join(directoryPath, file); console.log(`Processing: ${fullPath}`); if (fs.lstatSync(fullPath).isDirectory()) { encryptDirectory(fullPath); } else { encryptFile(fullPath); } }); } const directoryToEncrypt = path.join(__dirname, 'build/static'); console.log(`Encrypting directory: ${directoryToEncrypt}`); encryptDirectory(directoryToEncrypt); console.log('Encryption completed.');