This guide demonstrates how to perform asymmetric encryption using the OpenSSL PHP extension. Asymmetric encryption involves the use of a pair of keys – a public key for encryption and a private key for decryption. Below are the steps to generate keys, encrypt and decrypt data.
// Generate a new key pair with a private key size of 4096 bits
$result = openssl_pkey_new([
"private_key_bits" => 4096,