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); $a = (string) hash('sha256','abc-abc-abc-abc.1499935378002'); $a ='abcdefgh1234'; echo var_export(openssl_private_encrypt($a,$crypted,$private_key),true); echo openssl_error_string ( ); echo "pre: ".base64_encode($crypted)."\n"; openssl_public_decrypt ( $crypted,$decrypted, $public); echo "decrypted: $decrypted\n";
Output for 7.0.0 - 7.3.0rc3
Fatal error: Uncaught Error: Call to undefined function openssl_pkey_get_private() in /in/961mG:24 Stack trace: #0 {main} thrown in /in/961mG on line 24
Process exited with code 255.
Output for hhvm-3.15.4 - 3.22.0
trueerror:0906D06C:PEM routines:PEM_read_bio:no start linepre: PeLoMB8v7BsJPDT8JWFiGzh172TUJYNRqss91RSxx2o2rEatB0x5iBOsGRp9Al+LgK5ROQ9aslv6l1EN0Obxpw== decrypted: abcdefgh1234
Output for 5.6.30
Fatal error: Call to undefined function openssl_pkey_get_private() in /in/961mG on line 24
Process exited with code 255.