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

Stringdecrypt(String content, String password)
decrypt
byte[] data = null;
try {
    data = hex2byte(content);
} catch (Exception e) {
    e.printStackTrace();
data = decrypt(data, password);
if (data == null)
...
Stringdecrypt(String data)
decrypt
try {
    SecretKeySpec sks = null;
    byte[] decodedBytes = null;
    byte[] encodedBytes = Base64.decode(data, Base64.DEFAULT);
    SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
    sr.setSeed(seed.getBytes());
    KeyGenerator kg = KeyGenerator.getInstance("AES");
    kg.init(128, sr);
...
Stringdecrypt(String dataPassword, String encrypted)
decrypt
byte[] byteMi = Base64.decodeBase64(encrypted);
IvParameterSpec zeroIv = new IvParameterSpec(ENCRYPT_IV);
SecretKeySpec key = new SecretKeySpec(dataPassword.getBytes(),
        "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key, zeroIv);
byte[] decryptedData = cipher.doFinal(byteMi);
return new String(decryptedData, CHARSET);
...
Stringdecrypt(String encrypted)
decrypt
byte[] seedByte = theRawKey.getBytes();
System.arraycopy(seedByte, 0, key, 0,
        ((seedByte.length < 16) ? seedByte.length : 16));
String base64 = new String(Base64.decode(encrypted, 0));
byte[] rawKey = getRawKey(seedByte);
byte[] enc = toByte(base64);
byte[] result = decrypt(rawKey, enc);
return new String(result);
...
Stringdecrypt(String key, String encrypted)
decrypt
byte[] rawKey = getRawKey(key.getBytes());
byte[] enc = toByte(encrypted);
byte[] result = decrypt(rawKey, enc);
return new String(result);
Stringdecrypt(String key, String src)
decrypt
byte[] keyByte = key.getBytes();
SecretKeySpec keySpec = new SecretKeySpec(keyByte, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
IvParameterSpec ivSpec = new IvParameterSpec(iv);
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
byte[] srcByte = Base64.decode(src, Base64.DEFAULT);
byte[] decrypted = cipher.doFinal(srcByte);
String result = new String(decrypted);
...
Stringdecrypt(String seed, String encrypted)
decrypt
byte[] rawKey = getRawKey(seed.getBytes());
byte[] enc = toByte(encrypted);
byte[] result = decrypt(rawKey, enc);
return new String(result);
Stringdecrypt(String seed, String encrypted)
decrypt
byte[] rawKey;
try {
    rawKey = getRawKey(seed.getBytes());
    byte[] enc = toByte(encrypted);
    byte[] result = decrypt(rawKey, enc);
    String coentn = new String(result);
    return coentn;
} catch (Exception e) {
...
Stringdecrypt(String seed, String encrypted)
To decrypt a string.
byte[] rawKey;
try {
    rawKey = getRawKey(seed.getBytes());
    byte[] enc = toByte(encrypted);
    byte[] result = decrypt(rawKey, enc);
    String coentn = new String(result);
    return coentn;
} catch (Exception e) {
...
Stringdecrypt(String src)
decrypt
String decrypted = "";
try {
    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    cipher.init(Cipher.DECRYPT_MODE, makeKey(), makeIv());
    decrypted = new String(cipher.doFinal(Base64.decode(src,
            Base64.NO_WRAP)));
} catch (Exception e) {
    throw new RuntimeException(e);
...