So I have this line of code:
$signature = openssl_decrypt(base64_decode($signature), 'AES-256-CBC', $apiKey->private_key, 0, $iv);
And in my Android application I have this:
public String encrypt(String message, String privateKey) throws Exception{
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
IvParameterSpec iv = makeIv();
cipher.init(Cipher.ENCRYPT_MODE, makeKey(privateKey), iv);
return Base64.encodeToString(cipher.doFinal(message.getBytes()), Base64.DEFAULT);
}
And when I encrypt something in Java and send it to PHP, there, I get different output from decryption following with signature check failure.
What is the right way to encrypt on Java/Android
side so that I can decrypt it in PHP like the line above shows?
Note: Do not worry about IV as I have a mechanism of exchanging it so I am using the same one for encryption and decryption.