Runtime Decryption in WebLogic
import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import java.util.Base64; public class KeyGeneratorExample { public static void main(String[] args) throws Exception { KeyGenerator keyGen = KeyGenerator.getInstance("AES"); keyGen.init(256); // 256-bit key SecretKey secretKey = keyGen.generateKey(); String encodedKey = Base64.getEncoder().encodeToString(secretKey.getEncoded()); System.out.println("AES Key: " + encodedKey); } }import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Base64; public class EncryptClassFile { public static void main(String[] args) throws Exception { String key = "your_base64_encoded_key"; // Replace with your key byte[] keyBytes = Base64.getDecoder().decode(key); SecretKeySpec secretKey = new SecretKeySpec(keyBytes, "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); byte[] classFileBytes = Files.readAllBytes(Paths.get("YourClassFile.class")); byte[] encryptedClassFile = cipher.doFinal(classFileBytes); Files.write(Paths.get("YourClassFile.class.enc"), encryptedClassFile); System.out.println("Class file encrypted successfully."); } }
Important Considerations
Last updated