Skip to content Skip to sidebar Skip to footer

Decrypt Data Using Rsa Between Php And Java Android Issue

I am using a PHP server to encrypt some data and then decrypt it to an Android device. But when I try to decrypt it on the Android device side, I get the following error : javax.c

Solution 1:

You might need to do define('CRYPT_RSA_PKCS15_COMPAT', true).

The following comment block elaborates:

https://github.com/phpseclib/phpseclib/blob/a8c2ff0fb013169193c649adab512cafef5068cf/phpseclib/Crypt/RSA.php#L2272

Basically, OpenSSL (and quite potentially Java too) implements PKCS#1 v1.5 whereas phpseclib implements PKCS#1 v2.1. PKCS#1 v2.1 modifies PKCS1 style encryption to make use of randomized padding so no two ciphertext's will ever be the same.

Post a Comment for "Decrypt Data Using Rsa Between Php And Java Android Issue"