AES decrypt byte array with byte array key and return byte array - Android java.security

Android examples for java.security:AES

Description

AES decrypt byte array with byte array key and return byte array

Demo Code

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

public class Main {

  public static byte[] decrypt(byte[] key, byte[] input) throws Exception {
    Cipher cipher = Cipher.getInstance("AES");
    cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"));
    byte[] decrypted = cipher.doFinal(input);
    return decrypted;
  }/*from   w w w. j  av a2  s.co  m*/

}

Related Tutorials