Here you can find the source of aesDecryptByBytes(byte[] encryptBytes, String decryptKey)
public static String aesDecryptByBytes(byte[] encryptBytes, String decryptKey)
//package com.java2s; //License from project: Open Source License import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.spec.SecretKeySpec; public class Main { public static String aesDecryptByBytes(byte[] encryptBytes, String decryptKey) { if (encryptBytes == null || decryptKey == null) { return null; }//from ww w. ja v a2s . c o m try { KeyGenerator kgen = KeyGenerator.getInstance("AES"); kgen.init(128, new SecureRandom(decryptKey.getBytes())); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(kgen.generateKey().getEncoded(), "AES")); byte[] decryptBytes = cipher.doFinal(encryptBytes); return new String(decryptBytes); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }