signing using RSA public key algorithm
I am planning to use php for generating serial number for my software which is written using MSVC++. The method开发者_如何学C i am optiong is hashing the information and sign it using Private key. In MSVC++ i am able to verify a hash signed by RSA public key algorithm using native API's. Is it possible to sign a hash using RSA public key algorithm in php.
Please advice.
Regards, John.
Try phpseclib, a pure PHP RSA implementation:
<?php
include('Crypt/RSA.php');
$rsa = new Crypt_RSA();
extract($rsa->createKey());
$plaintext = 'terrafrost';
$rsa->loadKey($privatekey);
$signature = $rsa->sign($plaintext);
$rsa->loadKey($publickey);
echo $rsa->verify($plaintext, $signature) ? 'verified' : 'unverified';
?>
The problem with the solution poelinca proposed is that it's not PKCS#1 compliant (which means, among other things, that it's very likely not going to be interoperable with MSVC++), it doesn't work with standardized key formats and it doesn't employ RSA blinding (meaning one can use timing attacks to figure out the private key).
I don't understand what you're saying with "sign a hash" , however would Encrypt and decrypt data with RSA public keys be of any help ?
精彩评论