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?
I guess that you've already found a solution for your problem since, but here is a little examle to use RSA between Javascript and PHP for those who are still looking for a solution (example):
If you need more examples, visit the official website for documentation at : http://phpseclib.sourceforge.net/new/rsa/examples.html
or
http://bestmike007.com/2011/08/secure-data-transmission-between-pure-php-and-javascript-using-rsa/