Hi,

if I encrypt the same data with the same public key I get different
encrypted data back which I (in 9 of 10 cases) cannot decrypt with my
private key. Here's the details:

$string="Some Important Data"; // <- This is what I want to encrypt
$fp=fopen ("server.crt","r"); // read the public key
$pub_key=fread ($fp,8192);
fclose($fp);
$PK="";
$PK=openssl_get_publickey($pub_key);
if (!$PK) {
   echo "Cannot get public key $pub_key";
}

$finaltext1="";
$finaltext2="";
$finaltext3="";
openssl_public_encrypt($string,$finaltext1,$PK); // encrypt string with
key $PK
openssl_public_encrypt($string,$finaltext2,$PK); // encrypt string with
key $PK (2nd time)
openssl_public_encrypt($string,$finaltext3,$PK); // encrypt string with
key $PK (3rd time)
print " <HR>$finaltext<HR><BR>
        <HR>$finaltext2<HR><BR>
        <HR>$finaltext3<HR><BR>";

Maybe I'm wrong but shouldn't $finaltext1 be the same as $finaltext2 and
$finaltext3 ??

Thanks for your help!

Jochen

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to