openssl_pkey_new

PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8
openssl_pkey_new - Generates a new private key
Manual
Code Examples

openssl_pkey_new( [array|null$options = null] ): OpenSSLAsymmetricKey|false

openssl_pkey_new generates a new private key. How to obtain the public component of the key is shown in an example below.

Note:

You need to have a valid openssl.cnf installed for this function to operate correctly. See the notes under the installation section for more information.

Parameters

options

You can finetune the key generation (such as specifying the number of bits) using options. See openssl_csr_new for more information about options.

Return Values

Returns an OpenSSLAsymmetricKey instance for the pkey on success, or false on error.

Changelog

Version Description
8.0.0 On success, this function returns an OpenSSLAsymmetricKey instance now; previously, a resource of type OpenSSL key was returned.
7.1.0 The curve_name option was added to make it possible to create EC keys.

Example of openssl_pkey_new

Show all examples for openssl_pkey_new

PHP Version:


Function openssl_pkey_new:

OpenSSL Functions

Most used PHP functions