public class AESUtils {
public static final String DEFAULT_CODING = "utf-8";
/**
* 解密
* @param encrypted 需要解密的密文字符串
* @param key 密钥
* @return
* @throws Exception
*/
public static String decrypt(String encrypted, String key) throws Exception {
byte[] keyb = key.getBytes(DEFAULT_CODING);
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] thedigest = md.digest(keyb);
SecretKeySpec skey = new SecretKeySpec(thedigest, "AES");
Cipher dcipher = Cipher.getInstance("AES");
dcipher.init(Cipher.DECRYPT_MODE, skey);
byte[] clearbyte = dcipher.doFinal(toByte(encrypted));
return new String(clearbyte);
}
public static String decryptByKey(String e