Java RSA + PHP openssl compatibility
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, April 26, 2010 06:03 PM

Hello All! I'm trying to make work together client/server application I have Java client which uses standard libs for work with RSA import java.security.* import javax.crypto.* PublicKey publicKey = ... Cipher c = Cipher.getInstance("RSA"); c.init(Cipher.ENCRYPT_MODE, publicKey); byte[] encrypted = c.doFinal(message.getBytes()); this client sends encrypted data to server side script PHP which have to decrypt it: $privateKey = openssl_pkey_get_private('file://'.$path_private, null); openssl_private_decrypt($encryptedData, $sensitiveData, $privateKey); echo $sensitiveData; but I have probl   More>>

Hello All!

I'm trying to make work together client/server application

I have Java client which uses standard libs for work with RSA
import java.security.*
import javax.crypto.*


			
PublicKey publicKey = ...
Cipher c = Cipher.getInstance("RSA");
c.init(Cipher.ENCRYPT_MODE, publicKey);
byte[] encrypted = c.doFinal(message.getBytes());


this client sends encrypted data to server side script PHP which have to decrypt it:

			
$privateKey = openssl_pkey_get_private('file://'.$path_private, null);
openssl_private_decrypt($encryptedData, $sensitiveData, $privateKey);
echo $sensitiveData;


but I have problem with comminnicationg these parts together.

Java bytes are numbers are -128..127, PHP bytes: 0..255
so these data types are incompatible.

Any ideas, how to make communicate these functions in Java and PHP together?

regards, Alex    <<Less

Re: Java RSA + PHP openssl compatibility

Posted By:   alfredalfie  
Posted On:   Thursday, June 14, 2012 02:48 AM

PhpGedView an open source genealogy database program which compliments the recent introduction of PHP, MySql and PHP-Enabled Web Servers to the package list. I have added some notes at PhpGedView Notes.  car accidents minnesota

Re: Java RSA + PHP openssl compatibility

Posted By:   Anonymous  
Posted On:   Wednesday, April 28, 2010 12:30 PM

phpseclib - a pure PHP RSA implementation - has been demonstrated to be compatible with Bouncy Castle and OpenSSL:



http://www.frostjedi.com/phpbb/viewtopic.php?f=46&t=16797

http://stackoverflow.com/questions/2608541/rsa-encrypt-in-php-to-decrypt-in-net/2613865#2613865



Might be easier to use than PHP's OpenSSL bindings.

About | Sitemap | Contact