note 111769 added to function.openssl-pkey-new
| From: | dirt at awoms dot com | Date: | Tue, 26 Mar 2013 20:52:11 +0000 |
| Subject: | note 111769 added to function.openssl-pkey-new | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194222@lists.php.net to get a copy of this message | ||
Working example:
$config = array(
"digest_alg" => "sha512",
"private_key_bits" => 4096,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
);
// Create the private and public key
$res = openssl_pkey_new($config);
// Extract the private key from $res to $privKey
openssl_pkey_export($res, $privKey);
// Extract the public key from $res to $pubKey
$pubKey = openssl_pkey_get_details($res);
$pubKey = $pubKey["key"];
$data = 'plaintext data goes here';
// Encrypt the data to $encrypted using the public key
openssl_public_encrypt($data, $encrypted, $pubKey);
// Decrypt the data using the private key and store the results in $decrypted
openssl_private_decrypt($encrypted, $decrypted, $privKey);
echo $decrypted;
----
Server IP: 69.147.83.199
Probable Submitter: 71.122.134.130
----
Manual Page -- http://php.net/manual/en/function.openssl-pkey-new.php
Edit -- https://master.php.net/note/edit/111769
Del: integrated -- https://master.php.net/note/delete/111769/integrated
Del: useless -- https://master.php.net/note/delete/111769/useless
Del: bad code -- https://master.php.net/note/delete/111769/bad+code
Del: spam -- https://master.php.net/note/delete/111769/spam
Del: non-english -- https://master.php.net/note/delete/111769/non-english
Del: in docs -- https://master.php.net/note/delete/111769/in+docs
Del: other reasons-- https://master.php.net/note/delete/111769
Reject -- https://master.php.net/note/reject/111769
Search -- https://master.php.net/manage/user-notes.php