now , i ONLY have the modulus and exponent.
How should i do to encrypt using modulus and exponent in PHP?
It costed me much time that serching the answer in internet, but all was useless.
Thanks for your time
now , i ONLY have the modulus and exponent.
How should i do to encrypt using modulus and exponent in PHP?
It costed me much time that serching the answer in internet, but all was useless.
Thanks for your time
Using phpseclib, a pure PHP RSA implementation,
<?php
include('Crypt/RSA.php');
$rsa = new Crypt_RSA();
$rsa->loadKey(
array(
'e' => new Math_BigInteger('...'),
'n' => new Math_BigInteger('...')
)
);
$rsa->encrypt('...');
A discussion of the various number formats supported by Math_BigInteger can be found here:
http://phpseclib.sourceforge.net/math/examples.html#constructor
Note that phpseclib follows the PKCS1 standards and pads plaintext's. Since it sounds like your RSA key isn't formated in an industry standard way I'm going to guess you're not wanting to use industry standard padding either. So what you'll want to do is this:
$plaintext = new Math_BigInteger('aaaaaa');
echo $rsa->_exponentiate($plaintext)->toBytes();
Do note that doing RSA encryption like that is quite insecure but I'll leave that consideration up to you.