Java tutorial
//package com.java2s; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; public class Main { public static byte[] decodeFile(byte[] key, byte[] fileData, boolean isPlainText) throws Exception { byte[] decrypted; if (!isPlainText) { decrypted = new byte[fileData.length - key.length * 2]; System.arraycopy(fileData, key.length, decrypted, 0, decrypted.length); } else { SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, skeySpec); decrypted = cipher.doFinal(fileData); } return decrypted; } }