3v4l.org

run code in 300+ PHP versions simultaneously
<?php $private_key_string = <<<__EOF__ -----BEGIN RSA PRIVATE KEY----- MIIBOwIBAAJBANWj431rbsGw3f6rmED2gN0sKaxxDGvFB/M+o6OwnHGEtz7tL1bz J3wUEHzUkt4EelafK7KHNfOZ45mwmeviPn8CAwEAAQJAYj3oKc+Scf1cSHUuIYl5 fruFOmgN9yz21/ORGn/noQc4HS04VynMhzojs5MVIGTFVW1KTn8L4CdQ9iIHHPO4 SQIhAPkb7XKPrCif9XnJSa8l2roMzBYbUXQeeMHW46OzehGlAiEA24zJgypJ3F8t FLqRwXLH0eMr1D50vbPWcmeAWx5hjlMCIQCtPIa8jL2k4tjLgPgFHcYmbI/hL85N eoNwCgj05vOVIQIgScOUlNgpdrwXhmZkwE0TK8aanDXbvTzl6QwzSOn9NvcCIQCS zYIZywZTRueYk3YQCTX3ofnQad7M9X2802tWqm0q6A== -----END RSA PRIVATE KEY----- __EOF__; $public_key_string = <<<__EOF__ -----BEGIN PUBLIC KEY----- MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANWj431rbsGw3f6rmED2gN0sKaxxDGvF B/M+o6OwnHGEtz7tL1bzJ3wUEHzUkt4EelafK7KHNfOZ45mwmeviPn8CAwEAAQ== -----END PUBLIC KEY----- __EOF__; $private_key = openssl_pkey_get_private($private_key_string); $public_key = openssl_pkey_get_public($public_key_string); if (!$private_key) { echo "Cannot get private key\n"; } if (!$public_key) { echo "Cannot get public key\n"; } $input = "abc"; echo "input: $input\n"; openssl_public_encrypt($input, $crypttext, $public_key); openssl_private_decrypt($crypttext, $decoded, $private_key); echo "encrypted: " . base64_decode($crypttext) . "\n"; echo "decrypted: $decoded\n"; $encrypted_encoded = "0aO2tBOUdXrXkASzjnYKydq+WDj6URLvBdKOhxbkXp2/kRTjOb4cGDxBURLGoJPi53rNlNsk8AVEB9e2AkWF1Q=="; $encrypted = base64_decode($encrypted_encoded); openssl_private_decrypt($encrypted, $decrypted, $private_key); echo "decrypted: $decrypted\n";
Output for 7.1.20 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught Error: Call to undefined function openssl_pkey_get_private() in /in/C9ttT:22 Stack trace: #0 {main} thrown in /in/C9ttT on line 22
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: Call to undefined function openssl_pkey_get_private() in /in/C9ttT:22 Stack trace: #0 {main} thrown in /in/C9ttT on line 22
Process exited with code 255.
Output for 7.1.10
input: abc encrypted: ׵����W�\i decrypted: abc decrypted:
Output for 7.1.7
input: abc encrypted: �n��1� ���x'� decrypted: abc decrypted:
Output for 7.1.6
input: abc encrypted: �Y�b9O���2�� decrypted: abc decrypted:
Output for 7.1.5
input: abc encrypted: ��dY����l- decrypted: abc decrypted:
Output for 7.1.0
input: abc encrypted: �t���uX��r��* decrypted: abc decrypted:
Output for 7.0.20
input: abc encrypted: �Ds�z1Y decrypted: abc decrypted:
Output for 7.0.6
input: abc encrypted: ��q0�����Zr decrypted: abc decrypted:
Output for 5.5.29, 5.6.10, 5.6.17, 5.6.19, 7.0.5
input: abc encrypted: decrypted: abc decrypted:
Output for 7.0.4
input: abc encrypted: �R�C7�m$��� decrypted: abc decrypted:
Output for 7.0.3
input: abc encrypted: (�2��Mq decrypted: abc decrypted:
Output for 7.0.2
input: abc encrypted: i�K* decrypted: abc decrypted:
Output for 7.0.1
input: abc encrypted: ��٦$ ��.H decrypted: abc decrypted:
Output for 7.0.0
input: abc encrypted: �:�� decrypted: abc decrypted:
Output for 5.6.28
input: abc encrypted: f� decrypted: abc decrypted:
Output for 5.6.21
input: abc encrypted: n0v��{ decrypted: abc decrypted:
Output for 5.6.20
input: abc encrypted: �V�@�Y㻮ϡ�);Ǥg decrypted: abc decrypted:
Output for 5.6.18
input: abc encrypted: yU��tl�Q���+ decrypted: abc decrypted:
Output for 5.6.16
input: abc encrypted: � decrypted: abc decrypted:
Output for 5.6.15
input: abc encrypted: �����/��.���W�m decrypted: abc decrypted:
Output for 5.6.14
input: abc encrypted: 7Da( i�]=\� decrypted: abc decrypted:
Output for 5.6.13
input: abc encrypted: �Л�P# decrypted: abc decrypted:
Output for 5.6.12
input: abc encrypted: ݱ�ԋx�� decrypted: abc decrypted:
Output for 5.6.11
input: abc encrypted: )�4t�&�C�, decrypted: abc decrypted:
Output for 5.6.9
input: abc encrypted: $o���� decrypted: abc decrypted:
Output for 5.6.8
input: abc encrypted: ��=@���i�u��9 decrypted: abc decrypted:
Output for 5.5.35
input: abc encrypted: ��w�� decrypted: abc decrypted:
Output for 5.5.34
input: abc encrypted: ��U|v��w�Ȑg decrypted: abc decrypted:
Output for 5.5.33
input: abc encrypted: Œ�a%@�M decrypted: abc decrypted:
Output for 5.5.32
input: abc encrypted: b��;D��:� decrypted: abc decrypted:
Output for 5.5.31
input: abc encrypted: ߕx���;�Ɔ� ϐ decrypted: abc decrypted:
Output for 5.5.30
input: abc encrypted: �K��� decrypted: abc decrypted:
Output for 5.5.28
input: abc encrypted: [KI�nͤ`� ��Z decrypted: abc decrypted:
Output for 5.5.27
input: abc encrypted: w���C��I4 decrypted: abc decrypted:
Output for 5.5.26
input: abc encrypted: Z�+N� decrypted: abc decrypted:
Output for 5.5.25
input: abc encrypted: �J���'x2��L decrypted: abc decrypted:
Output for 5.5.24
input: abc encrypted: ��W�2ٚ decrypted: abc decrypted:

preferences:
212.72 ms | 401 KiB | 225 Q