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'); openssl_private_encrypt((string)hash('sha256','abc-abc-abc-abc.1499935378002'),$crypted,$private_key); echo "pre: ".base64_encode($crypted)."\n"; openssl_public_decrypt ( $crypted,$decrypted, $public); echo "decrypted: $decrypted\n";