Advertisement
anta40

Java-AES-decrypt

Jan 7th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. public static String AES_decrypt(String inputMessage, String key) throws CryptoException, IOException,
  2.     CryptoTokenException, CryptoUnsupportedOperationException {
  3.    
  4.     AESKey aeskey = new AESKey(key.getBytes());
  5.     byte[] data = StringUtil.b64_decode(inputMessage);
  6.  
  7.     AESDecryptorEngine engine = new AESDecryptorEngine(aeskey);
  8.     PKCS5UnformatterEngine uengine = new PKCS5UnformatterEngine(engine);
  9.  
  10.     ByteArrayInputStream input = new ByteArrayInputStream(data);
  11.     BlockDecryptor decryptor = new BlockDecryptor(uengine, input);
  12.        
  13.     decryptor.read(data);
  14.     decryptor.close();
  15.     input.close();
  16.        
  17.     return input.toString();
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement