3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // This is a demo, decrypting a string which was encrypted here: https://repl.it/BhjH // CAUTION: This is a 512 bit RSA demo key - NEVER USE THIS SOMEWHERE FOR REAL! $private_key_string = <<<__EOF__ -----BEGIN RSA PRIVATE KEY----- MIIBOQIBAAJBAOhTYPPN5g/2CSnWflL39tXhvUUXNZYcd57TBiR2+ds7iB4bjivB IujlivE0xD8/GQD+8Pe12A4oYjmnHqfa620CAwEAAQJAUMAiU7t+Oo/+0V7vW3E6 h07GFYyioIFWhoq8eNItuCgIXCD3yA9Ox98JwYS9q/1WQiuw/gISOM+uZlaWlpKx dQIhAPzXgBaMVpuJmMdfgQ2Hhdg5dUUKBnSdOOLCjwv9AHujAiEA6zpGank0WaQg QLPlGr4eQt00vbMkuekwD23eD562ba8CICVlRiePmBunDTantHGo0q35SZPteKj0 u/4l4nxWbiTbAiAeWb6MLmdayZp/vrZo5O7yoagUcfDjK/tPglWMnmXbcQIgFKiP k6RAkp/k3ZsF0O1KJwC9n3UYl/SsMrp7S2Pj/Nk= -----END RSA PRIVATE KEY----- __EOF__; $public = <<<__asdfadF__ -----BEGIN PUBLIC KEY----- MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOhTYPPN5g/2CSnWflL39tXhvUUXNZYc d57TBiR2+ds7iB4bjivBIujlivE0xD8/GQD+8Pe12A4oYjmnHqfa620CAwEAAQ== -----END PUBLIC KEY----- __asdfadF__; $private_key = openssl_pkey_get_private($private_key_string); $public = openssl_pkey_get_public($public); openssl_private_encrypt('abc',$crypted,$private_key); openssl_public_decrypt ( $crypted,$decrypted, $public); echo "decrypted: $decrypted\n";
based on 3NKcb
Output for 7.1.20, 7.2.6 - 7.3.0rc3
Fatal error: Uncaught Error: Call to undefined function openssl_pkey_get_private() in /in/TDqCb:24 Stack trace: #0 {main} thrown in /in/TDqCb on line 24
Process exited with code 255.
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.1.10, 7.2.0
decrypted: abc