Created
April 21, 2012 18:16
-
-
Save bricef/2438921 to your computer and use it in GitHub Desktop.
AES Decryption in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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