3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = array( "digest_alg" => "sha1", "private_key_bits" => 1024, "private_key_type" => OPENSSL_KEYTYPE_RSA, ); // Create the private and public key $res = openssl_pkey_new($config); $output = ''; // Create the keypair //$res=openssl_pkey_new(); // Get private key openssl_pkey_export($res, $privatekey); $privatekey_string=base64_encode($privatekey); // Get public key $publickey=openssl_pkey_get_details($res); $publickey_string=base64_encode($publickey["key"]); echo "Private Key:<BR>$privatekey_string<br><br>Public Key:<BR>$publickey_string<BR><BR>"; $chunk="HelloWorld!"; openssl_private_encrypt($chunk, $encrypted, $privatekey,$padding = OPENSSL_NO_PADDING); $encrypted_string= base64_encode($encrypted); echo "Encrypted:<BR>$encrypted_string<br>";
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught Error: Undefined constant "OPENSSL_KEYTYPE_RSA" in /in/HNd9j:5 Stack trace: #0 {main} thrown in /in/HNd9j on line 5
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught Error: Undefined constant "OPENSSL_KEYTYPE_RSA" in /in/HNd9j:5 Stack trace: #0 {main} thrown in /in/HNd9j on line 5
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant OPENSSL_KEYTYPE_RSA - assumed 'OPENSSL_KEYTYPE_RSA' (this will throw an Error in a future version of PHP) in /in/HNd9j on line 5 Fatal error: Uncaught Error: Call to undefined function openssl_pkey_new() in /in/HNd9j:9 Stack trace: #0 {main} thrown in /in/HNd9j on line 9
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Notice: Use of undefined constant OPENSSL_KEYTYPE_RSA - assumed 'OPENSSL_KEYTYPE_RSA' in /in/HNd9j on line 5 Fatal error: Uncaught Error: Call to undefined function openssl_pkey_new() in /in/HNd9j:9 Stack trace: #0 {main} thrown in /in/HNd9j on line 9
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Notice: Use of undefined constant OPENSSL_KEYTYPE_RSA - assumed 'OPENSSL_KEYTYPE_RSA' in /in/HNd9j on line 5 Fatal error: Call to undefined function openssl_pkey_new() in /in/HNd9j on line 9
Process exited with code 255.

preferences:
269.03 ms | 402 KiB | 376 Q