Android Java和PHP加密(AES)不匹配

Android Java和PHP加密(AES)不匹配,php,android,encryption,cryptography,aes,Php,Android,Encryption,Cryptography,Aes,我有一行代码: $signature = openssl_decrypt(base64_decode($signature), 'AES-256-CBC', $apiKey->private_key, 0, $iv); 在我的Android应用程序中,我有: public String encrypt(String message, String privateKey) throws Exception{ Cipher cipher = Cipher.getInstance("A

我有一行代码:

$signature = openssl_decrypt(base64_decode($signature), 'AES-256-CBC', $apiKey->private_key, 0, $iv);
在我的Android应用程序中,我有:

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);
}
当我用Java加密某些东西并将其发送到PHP时,我从解密中得到不同的输出,然后签名检查失败

Java/Android
端加密的正确方法是什么,这样我就可以像上面的一行那样用PHP对其进行解密


注意:不要担心IV,因为我有一个交换机制,所以我使用相同的机制进行加密和解密。

那么,输出与预期的输出有何不同?长度一样吗?有些字节相同,有些字节不同(哪些字节)?是完全不同的吗?您的输入有多长(以字节为单位)?我从未打印过输出PHP,我假设它是错误的,但现在当检查openssl_decrypt时,它返回FALSE,并出现以下错误:
错误:060606506d:数字信封例程:EVP_decrypt final_ex:错误的最终块长度
Hmmm您能给我们看一下makey()函数吗?
私钥makeKey(字符串密钥){返回新的SecretKeySpec(key.getBytes(),“AES”);}