Here you can find the source of decrypt(String keyStr, String encryptData)
public static String decrypt(String keyStr, String encryptData)
//package com.java2s; import java.security.Key; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Base64; public class Main { private static final String AESTYPE = "AES/ECB/PKCS5Padding"; public static String decrypt(String keyStr, String encryptData) { byte[] decrypt = null; try {/*from ww w. j a va 2 s.co m*/ Key key = generateKey(keyStr); Cipher cipher = Cipher.getInstance(AESTYPE); cipher.init(Cipher.DECRYPT_MODE, key); decrypt = cipher.doFinal(Base64.decodeBase64(encryptData)); } catch (Exception e) { e.printStackTrace(); } return new String(decrypt).trim(); } private static Key generateKey(String key) throws Exception { try { SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "AES"); return keySpec; } catch (Exception e) { e.printStackTrace(); throw e; } } }