Here you can find the source of aesDecrypt(byte[] input, Key key)
public static byte[] aesDecrypt(byte[] input, Key key) throws Exception
//package com.java2s; /*//from ww w .j a va2s .c o m * Copyright (C) 2008-2015 by Holger Arndt * * This file is part of the Universal Java Matrix Package (UJMP). * See the NOTICE file distributed with this work for additional * information regarding copyright ownership and licensing. * * UJMP is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * UJMP is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with UJMP; if not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA */ import java.security.Key; import java.security.spec.AlgorithmParameterSpec; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; public class Main { public static final byte[] IV16 = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; public static byte[] aesDecrypt(byte[] input, Key key) throws Exception { return aesDecrypt(input, key, IV16); } public static byte[] aesDecrypt(byte[] input, byte[] key) throws Exception { return aesDecrypt(input, new SecretKeySpec(key, "AES"), IV16); } public static byte[] aesDecrypt(byte[] input, byte[] key, byte[] iv) throws Exception { return aesDecrypt(input, new SecretKeySpec(key, "AES"), iv); } public static byte[] aesDecrypt(byte[] input, Key secret, byte[] iv) throws Exception { AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, secret, paramSpec); return cipher.doFinal(input); } }