P E N C I L
Login
AES
  1. Key size: 
    1. In Java AES the length of the key must be 128-bit(16 bytes), 192-bit(24 bytes) or 256-bit(32 bytes).
      (20 bytes key length will produce exception InvalidKeyException)
    2. We don't have to declare the key length explicitly. It's the length of input key in 
      SecretKeySpec key = new SecretKeySpec(enc_key, "AES");
  2. AES Encrypt:
    Cipher cipher = Cipher.getInstance(AES_CIPHER_ALGORITHM);
    SecretKeySpec keySpec = new SecretKeySpec(key, SECRET_KEY_ALGORITHM);
    cipher.init(Cipher.ENCRYPT_MODE, keySpec, new IvParameterSpec(iv));
    return cipher.doFinal(plainText);
  3. AES decrypt:
    Cipher cipher = Cipher.getInstance(AES_CIPHER_ALGORITHM);
    SecretKeySpec keySpec = new SecretKeySpec(key, SECRET_KEY_ALGORITHM);
    cipher.init(Cipher.DECRYPT_MODE, keySpec, new IvParameterSpec(iv));
    return cipher.doFinal(cipherText);