Android Utililty Methods AES Decrypt

List of utility methods to do AES Decrypt

Description

The list of methods to do AES Decrypt are organized into topic(s).

Method

byte[]decrypt(byte[] data, byte[] key, String cipherAlgorithm)
decrypt
Key k = toKey(key);
return decrypt(data, k, cipherAlgorithm);
byte[]decrypt(byte[] encryptSource)
decrypt
if (encryptSource == null || encryptSource.length < 1) {
    return null;
return decryptCipher.doFinal(encryptSource);
byte[]decrypt(byte[] key, byte[] encrypted)
decrypt
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] decrypted = cipher.doFinal(encrypted);
return decrypted;
byte[]decrypt(byte[] key, byte[] src)
decrypt
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
return cipher.doFinal(src);
byte[]decrypt(byte[] raw, byte[] encrypted)
decrypt
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES"); 
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] decrypted = cipher.doFinal(encrypted);
return decrypted;
byte[]decrypt(byte[] raw, byte[] encrypted)
decrypt
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] decrypted = cipher.doFinal(encrypted);
return decrypted;
byte[]decrypt(byte[] raw, byte[] encrypted)
decrypt
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(
        new byte[cipher.getBlockSize()]));
byte[] decrypted = cipher.doFinal(encrypted);
return decrypted;
byte[]decrypt(byte[] raw, byte[] encrypted)
Actual decrypt data function.
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(
        new byte[cipher.getBlockSize()]));
byte[] decrypted = cipher.doFinal(encrypted);
return decrypted;
byte[]decrypt(byte[] textBytes, String key)
decrypt
byte[] keyBytes = key.getBytes("UTF-8");
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
SecretKeySpec newKey = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, newKey, ivSpec);
return cipher.doFinal(textBytes);
StringdecryptBase64(String content, String key)
decrypt Base
try {
    byte[] contentBytes = Base64.decodeBase64(content
            .getBytes(UTF_8));
    byte[] result = decrypt(contentBytes, key);
    return new String(result, UTF_8);
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
return null;