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[]decryptBase64(String encryptBase64)
decrypt Base
if (encryptBase64 == null || encryptBase64.trim().length() < 1) {
    return null;
byte[] encryptData = Base64.decode(encryptBase64, Base64.NO_WRAP);
return decryptCipher.doFinal(encryptData);
StringdecryptBase64Text(String key, String src)
decrypt Base Text
byte[] enc = Base64.decode(src, Base64.DEFAULT);
return decryptBytes(key, enc);
StringdecryptBytes(String key, byte[] src)
decrypt Bytes
byte[] rawKey = getRawKey(key);
return new String(decrypt(rawKey, src));
byte[]decryptBytes(String seed, byte[] encrypted)
decrypt Bytes
byte[] rawKey = getRawKey(seed.getBytes());
byte[] result = decrypt(rawKey, encrypted);
return result;
byte[]decryptBytes(byte[] data, byte[] key)
Decrypts data using the AES encryption cipher.
try {
    Cipher cipher = Cipher.getInstance("AES");
    SecretKeySpec sKey = new SecretKeySpec(key, "AES");
    cipher.init(Cipher.DECRYPT_MODE, sKey);
    return cipher.doFinal(data);
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
} catch (NoSuchPaddingException e) {
...
StringdecryptHex(String content, String key)
decrypt Hex
try {
    byte[] contentBytes = hexDecode(content);
    byte[] result = decrypt(contentBytes, key);
    return new String(result, UTF_8);
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
return null;
...
StringdecryptHex(String content, String username, String password)
decrypt Hex
return decryptHex(content, password + username);
StringdecryptNumberWithAES(String encrypted)
decrypt Number With AES
byte[] encryptedBytes = Base64.decode(encrypted, Base64.DEFAULT);
String keyString = "intrepidlearner1"; 
byte[] key = keyString.getBytes();
Cipher c = Cipher.getInstance("AES");
SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
c.init(Cipher.DECRYPT_MODE, keySpec);
byte[] decryptedData = c.doFinal(encryptedBytes);
return new String(decryptedData);
...
StringdecryptUrlDecode(String dataPassword, String encrypted)
decrypt Url Decode
return decrypt(dataPassword, URLDecoder.decode(encrypted, CHARSET));
StringaesDecode(String seed, String encrypted)
aes Decode
byte[] rawKey = getRawKey(seed.getBytes());
byte[] enc = toByte(encrypted);
byte[] result = decrypt(rawKey, enc);
return new String(result);