3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class CryptoHelper { public $pubkey = ""; public $privkey = ""; function __construct() { $this->pubkey = ("-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvHVvv1U1jae8a4mpkmda As8c0Yx0dpeqHiuJkErP01YFf5/6sw/YyzhbEANZMip4o3YukylmwvRQv2a29ZNo iL0HfJyzcYxfiEgGJ5EmYChMRdXZ0QPQi6Q8XtKxRc110bYJNDfpqDsh8vvz8tHD l4yFN0KA3iVvs6ZWEYoSkGu9qlJ319FKzW7JAIz0MFxu4fGEwEm5geDNBpwuqZhv IQUNXGYxFz2whYS13tEEPygLAeHH/AidYetrlYA0t4kG0R54sRBBRO7/EdPtEtE0 YTGzoeClIDkJd5FNj0UFvFL4gXOc+oES+rCwKWCAny1pbN+UC0lVlsWhTpTtfhio 7QIDAQAB -----END PUBLIC KEY-----"); $this->privkey = ( "-----BEGIN RSA PRIVATE KEY----- MIIEoQIBAAKCAQEAvHVvv1U1jae8a4mpkmdaAs8c0Yx0dpeqHiuJkErP01YFf5/6 sw/YyzhbEANZMip4o3YukylmwvRQv2a29ZNoiL0HfJyzcYxfiEgGJ5EmYChMRdXZ 0QPQi6Q8XtKxRc110bYJNDfpqDsh8vvz8tHDl4yFN0KA3iVvs6ZWEYoSkGu9qlJ3 19FKzW7JAIz0MFxu4fGEwEm5geDNBpwuqZhvIQUNXGYxFz2whYS13tEEPygLAeHH /AidYetrlYA0t4kG0R54sRBBRO7/EdPtEtE0YTGzoeClIDkJd5FNj0UFvFL4gXOc +oES+rCwKWCAny1pbN+UC0lVlsWhTpTtfhio7QIDAQABAoH/N/KlOigRvfwN897q eIw2LJ9P7uXDrXFZD5vdOvj6ucLP3xOfWYla0vnoDtjvofT52406RnYEC9x8HFZh +oXIgs+baWMb4pnJwqufKB/vRJyyCAl0oJiBUPNw+LWT6yUT1S41jUsMEuV7Lqed xHiBmHwfEEit+UUj5DF9W7ehyz2uHaU+u0KYffWpHZwY8vlCLcT5r3eEjy45AxMn jRl8m6LOVB6m0KvcyLXK9HHExD8nYGxalTn2Delb6x1/StH19by5l0QA4MwfLLSO +qWKHFWG3mwt80MsLjWfR5rr/A8WUMrQ2yMbW6n089Na7kRGYOhjWPtqji3Xv+hY XL+BAoGBAPBxWrir2ZBETgJJhEo89D5F+WV+BFwf7p4M8AH/kkrhiMuHlp3Jsn7o GRoDp3XwVm+kDfw0zAJHic7bYP4wwolKk8LXdQ7FtaB54UXJ/qzLaLoC62dnIdru SF5ScPahS0gA+poaIBPsOAbfESYcn3m6RZUT8T+6w4xgifVSFWnlAoGBAMinB1+W DjSiNHj83CgRe7N20ozidzTfl/hukKqOOIpJLWOiiOe7nR89LQjGJx5wc48pW3DP YzG8fokW1xN4O4hfI1nMKgmXeV6wG/kwjWoWNfxOSUnw3YFBQty/blPbGEowCWkd KzoFI2PYhDZHMkvXCfCh4vx4UZUrg+nKA7JpAoGBALSfctdnwXhu12tAbvCV+aUO S9vCXuQV2NtCPMpDg1JdOrYqlSrTahOLp8+zDwm6EjSruRXNU7QiqZOLmcFaP8mD DJ1B3d3LCDYVWPVkWLzV0UZrCwwSnYwplJPGurWLVVIx6g/5sD9HJI+E4w0OU37O P5dN8908H8pEe16e2xdBAoGAS/QuLli29+WOx12wWNqFYOHRwdLYHQOmmzv/NxCv Bmm87MJR4KZ8S570tSWNGVCn7cFSA9n9So53t50VvSD+KBkbYJqQLyFPqDAx5poi bc4KkX9w7rRmpM73aGhucv+0qiCU711DR6s6QklrgsBgoaS89oHRUpCZEUZvoMf/ rkECgYBHHCxrop30fWWYTRIxfzVQi5OsG/b/PiBj5f4Qa2huP+l91I/GIhrbXJ6l nHd+K9u8PE1+SWQWX8584C8KZkBn0lcJvH0VSJDoB2/FzgLpDp/sQBfyAhJobXxP xoEYe9RDrxR+kmYyIwcod0ZsXT5oJNQLe2I3ps1cHi2ZIvnjzA== -----END RSA PRIVATE KEY-----" ); } public function encrypt($data) { if( openssl_public_encrypt( $data, $encrypted, $this->pubkey ) ) { $data = base64_encode($encrypted); } else { echo "ERROR"; } return $data; } public function decrypt($data) { if( openssl_private_decrypt( base64_decode($data), $decrypted, $this->privkey, OPENSSL_PKCS1_PADDING ) ) { $data = $decrypted; } else { $data = ''; } return $data; } } $a = new CryptoHelper(); $data = ("ls2ly9xthLrmFX+E9Qzdt7GiBOfVB4hVaA9J99g9UgDbQDwSwfsHIKDRGnKc+7MZ 7aTVxod4HtVix3aSKtbgs5o60lQyMJ2AGXmcwSZU79K5eKcFg3Y+lTQ4l15NOTVw aggEM/XQHcxd+yXQ35fxPiZHdF44vMi1vYA+dkLQxebu/6mFt/49JniCFtKcwYKE OCrw7v7Le45X8cnNj3GoPJBvPRFqhu8lYc1KH0FF/h6rLNVY28wVk4UJRQBDZLn9 0cVRYRJHbnuDFfHLVGJN0/CFIbBWGZvkqnW1o7Yk+f10wuuHt9Bn/tzt5f5JDZVx z/gPGhMrHw5PpA5979AIkQ=="); echo "CRYPTED DATA : $data\n\n"; echo "Decrypt : ".$a->decrypt($data)."\n"; ?>
Output for 7.0.0 - 7.3.5
CRYPTED DATA : ls2ly9xthLrmFX+E9Qzdt7GiBOfVB4hVaA9J99g9UgDbQDwSwfsHIKDRGnKc+7MZ 7aTVxod4HtVix3aSKtbgs5o60lQyMJ2AGXmcwSZU79K5eKcFg3Y+lTQ4l15NOTVw aggEM/XQHcxd+yXQ35fxPiZHdF44vMi1vYA+dkLQxebu/6mFt/49JniCFtKcwYKE OCrw7v7Le45X8cnNj3GoPJBvPRFqhu8lYc1KH0FF/h6rLNVY28wVk4UJRQBDZLn9 0cVRYRJHbnuDFfHLVGJN0/CFIbBWGZvkqnW1o7Yk+f10wuuHt9Bn/tzt5f5JDZVx z/gPGhMrHw5PpA5979AIkQ== Fatal error: Uncaught Error: Call to undefined function openssl_private_decrypt() in /in/fcl9n:65 Stack trace: #0 /in/fcl9n(88): CryptoHelper->decrypt('ls2ly9xthLrmFX+...') #1 {main} thrown in /in/fcl9n on line 65
Process exited with code 255.
Output for hhvm-3.10.1 - 3.22.0
CRYPTED DATA : ls2ly9xthLrmFX+E9Qzdt7GiBOfVB4hVaA9J99g9UgDbQDwSwfsHIKDRGnKc+7MZ 7aTVxod4HtVix3aSKtbgs5o60lQyMJ2AGXmcwSZU79K5eKcFg3Y+lTQ4l15NOTVw aggEM/XQHcxd+yXQ35fxPiZHdF44vMi1vYA+dkLQxebu/6mFt/49JniCFtKcwYKE OCrw7v7Le45X8cnNj3GoPJBvPRFqhu8lYc1KH0FF/h6rLNVY28wVk4UJRQBDZLn9 0cVRYRJHbnuDFfHLVGJN0/CFIbBWGZvkqnW1o7Yk+f10wuuHt9Bn/tzt5f5JDZVx z/gPGhMrHw5PpA5979AIkQ== Decrypt : la pappuja fiuta l'eba
Output for 5.0.0 - 5.6.40
CRYPTED DATA : ls2ly9xthLrmFX+E9Qzdt7GiBOfVB4hVaA9J99g9UgDbQDwSwfsHIKDRGnKc+7MZ 7aTVxod4HtVix3aSKtbgs5o60lQyMJ2AGXmcwSZU79K5eKcFg3Y+lTQ4l15NOTVw aggEM/XQHcxd+yXQ35fxPiZHdF44vMi1vYA+dkLQxebu/6mFt/49JniCFtKcwYKE OCrw7v7Le45X8cnNj3GoPJBvPRFqhu8lYc1KH0FF/h6rLNVY28wVk4UJRQBDZLn9 0cVRYRJHbnuDFfHLVGJN0/CFIbBWGZvkqnW1o7Yk+f10wuuHt9Bn/tzt5f5JDZVx z/gPGhMrHw5PpA5979AIkQ== Fatal error: Call to undefined function openssl_private_decrypt() in /in/fcl9n on line 65
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/fcl9n on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/fcl9n on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/fcl9n on line 6
Process exited with code 255.