I have trying to do encryption/decryption in Javascript/PHP using PKCS#1. I have the following variables:
e: Public exponent (for encryption)
d: Private exponent (for decryption)
n: modulus
I am using this javascript library to decrypt: http://www-cs-students.stanford.edu/~tjw/jsbn/rsa.js like this:
var rsa = new RSAKey();
rsa.setPublic(n, e);
var cipherText = rsa.encrypt(plainText);
To decrypt in PHP I use PHPSec library:
Question1: How do I convert from d and n to a private key to be used in phpseclib?
Question2: How do I convert the output from the Javascript code to a form that can be used with phpseclib?
For javascript / PHP interoperability check out this:
http://area51.phpbb.com/phpBB/viewtopic.php?f=84&t=33024&start=0
It does PKCS#1 v2.1 RSAES-OAEP (which is supposed to offer better security than PKCS#1 v2.1 RSASSA-PKCS1-v1_5).
$rsa->loadKey( array( 'e' => new Math_BigInteger('...', 256), 'n' => new Math_BigInteger('...', 256) ) );
If that doesn't work let me know.
Alternatively, you could try this:
http://www.frostjedi.com/phpbb3/viewtopic.php?p=331621#p331621
(see the second code block)
For converting the js output to a format PHP could use... the proof of concept I linked to is passing the output to char2hex():
Good luck!