Skip to content

Instantly share code, notes, and snippets.

@bricef
Created April 21, 2012 18:16
Show Gist options
  • Save bricef/2438921 to your computer and use it in GitHub Desktop.
Save bricef/2438921 to your computer and use it in GitHub Desktop.
AES Decryption in Java
public static String decrypt(byte[] cipherText, String encryptionKey) throws Exception{
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding", "SunJCE");
SecretKeySpec key = new SecretKeySpec(encryptionKey.getBytes("UTF-8"), "AES");
cipher.init(Cipher.DECRYPT_MODE, key,new IvParameterSpec(IV.getBytes("UTF-8")));
return new String(cipher.doFinal(cipherText),"UTF-8");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment