developers. I would want to have some info about open_ssl_encrypt with public and private keys.
I have a project and i must encrypt data from *PDF file than to decrypt it when it needed to be.
i have use the following example to generate a private and public key.
$pkGenerate = openssl_pkey_new(array(
'private_key_bits' => 2048,
'private_key_type' => OPENSSL_KEYTYPE_RSA
));
openssl_pkey_export($pkGenerate,$pkGeneratePrivate); // NOTE: second argument is passed by reference
$pkGenerateDetails = openssl_pkey_get_details($pkGenerate);
$pkGeneratePublic = $pkGenerateDetails['key'];
openssl_pkey_free($pkGenerate);
$pkImport = openssl_pkey_get_private($pkGeneratePrivate); // import
$pkImportDetails = openssl_pkey_get_details($pkImport); // same as getting the public key in previous
$pkImportPublic = $pkImportDetails['key'];
openssl_pkey_free($pkImport); // clean up
echo "
".$pkGeneratePrivate
."
".$pkGeneratePublic
."
".$pkImportPublic
."
".'Public keys are '.(strcmp($pkGeneratePublic,$pkImportPublic)?'different':'identical').'.';
So in my mind, i think i must generate a private key, and encrypt the data with it, than the data can only be decrypted by the public key witch is a part of the private key.Correct me if i am wrong..
next step i do.
openssl_private_decrypt ( $loadedPDF , $decryptedPDF , $pkGeneratePrivate );
echo $pkGeneratePrivate;
But nothings happend, can someone help me with my issue, thank you for spending your time with my problems,
Best Regrats!