Here you can find the source of aesEncryptBytes(byte[] pBytes, SecretKeySpec pKeySpec, IvParameterSpec ivParameterSpec)
public static byte[] aesEncryptBytes(byte[] pBytes, SecretKeySpec pKeySpec, IvParameterSpec ivParameterSpec) throws NoSuchAlgorithmException, NoSuchPaddingException, BadPaddingException, InvalidKeyException, IllegalBlockSizeException, InvalidAlgorithmParameterException
//package com.java2s; //License from project: Open Source License import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.security.*; public class Main { public static byte[] aesEncryptBytes(byte[] pBytes, SecretKeySpec pKeySpec, IvParameterSpec ivParameterSpec) throws NoSuchAlgorithmException, NoSuchPaddingException, BadPaddingException, InvalidKeyException, IllegalBlockSizeException, InvalidAlgorithmParameterException { Cipher cipher = getAESCipher(); cipher.init(Cipher.ENCRYPT_MODE, pKeySpec, ivParameterSpec); return cipher.doFinal(pBytes); }/*ww w .j a v a 2 s .c o m*/ private static Cipher getAESCipher() throws NoSuchPaddingException, NoSuchAlgorithmException { return Cipher.getInstance("AES/CBC/PKCS5Padding"); } }