I'm trying to send encrypted data from my android app to a PHP scripts that decrypts the data.
In android I use the following encryption method:
public String encryptAES(String key, String mdp) throws NoSuchPaddingException, NoSuchAlgorithmException {
byte[] skey = key.getBytes();
byte[] pwd = mdp.getBytes();
byte[] encrypted = null;
SecretKeySpec secretKeySpec = new SecretKeySpec(skey, "AES");
Cipher cipher = Cipher.getInstance("AES");
try {
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
} catch (InvalidKeyException e) {
e.printStackTrace();
}
try {
encrypted = cipher.doFinal(pwd);
} catch (IllegalBlockSizeException | BadPaddingException e) {
e.printStackTrace();
}
return Arrays.toString(Base64.encode(encrypted, Base64.DEFAULT));
}
and I use this to decrypt in PHP:
$data = mcrypt_decrypt(MCRYPT_RIJNADEAL_128, $key, $cipherText, MCRYPT_MODE_ECB);
The problem is that it doesn't decrypt to the wanted plain text in PHP.