Unencrypt String Using AES Algorithm

Unencrypt a String that was encrypted using AES algorithm.

Javadoc available at https://www.javatapas.com/docs/javatapas/string/UnencryptString.html


public static String unencryptString(SecretKey secretKey, String inStr) throws NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, NoSuchPaddingException, BadPaddingException {

  Cipher cipher = Cipher.getInstance("AES");

  cipher.init(Cipher.DECRYPT_MODE, secretKey);

  byte[] original = cipher.doFinal(inStr.getBytes());

  String unencryptedString = new String(original);

  return unencryptedString;

}