Android code
String apiResponse = \"EcUZvMif
Method:
protected void decryptDataWithAES(String apiResponse,
You are trying to decrypt the "key", I think you need to decrypt the apiResponse
Also you need the exact same IV the message was encrypted with, otherwise you won't be able to decrypt
Here is a static method to decrypt using AES with secretKey
private final static String AES_PADDING = "AES/ECB/PKCS5PADDING"; //this need to be same as DECRYPTION
private String secretKey = "Your secret key"; //your secret key
//DecryptString
@SuppressLint("GetInstance")
public static String AESDecryptionString(String encryptedStringData) {
Cipher decipher = null;
byte[] encryptedString = encryptedStringData.getBytes(StandardCharsets.ISO_8859_1);
String returnData = encryptedStringData;
try {
decipher = Cipher.getInstance(AES_PADDING);
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
e.printStackTrace();
}
byte[] decryption;
try {
assert decipher != null;
decipher.init(Cipher.DECRYPT_MODE, secretKey);
decryption = decipher.doFinal(encryptedString);
returnData = new String(decryption);
} catch (InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
e.printStackTrace();
}
return returnData;
}
You can also use my library to encrypt/decrypt string using AES