<?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-----
MIIBOwIBAAJBANWj431rbsGw3f6rmED2gN0sKaxxDGvFB/M+o6OwnHGEtz7tL1bz
J3wUEHzUkt4EelafK7KHNfOZ45mwmeviPn8CAwEAAQJAYj3oKc+Scf1cSHUuIYl5
fruFOmgN9yz21/ORGn/noQc4HS04VynMhzojs5MVIGTFVW1KTn8L4CdQ9iIHHPO4
SQIhAPkb7XKPrCif9XnJSa8l2roMzBYbUXQeeMHW46OzehGlAiEA24zJgypJ3F8t
FLqRwXLH0eMr1D50vbPWcmeAWx5hjlMCIQCtPIa8jL2k4tjLgPgFHcYmbI/hL85N
eoNwCgj05vOVIQIgScOUlNgpdrwXhmZkwE0TK8aanDXbvTzl6QwzSOn9NvcCIQCS
zYIZywZTRueYk3YQCTX3ofnQad7M9X2802tWqm0q6A==
-----END RSA PRIVATE KEY-----
__EOF__;
$private_key = openssl_pkey_get_private($private_key_string);
$encrypted_encoded = "WetPszXfBK3iJgvOh0Wst+j7hBEJbYNGCmR+bgZZNglNsHTBh/ewVS04XpyJUnMTgjvLSoPaCbQ1SIpxJh7eXg==";
$encrypted = base64_decode($encrypted_encoded);
openssl_private_decrypt($encrypted, $decrypted, $private_key);
echo "decrypted: $decrypted\n";
Fatal error: Uncaught Error: Call to undefined function openssl_pkey_get_private() in /in/3NKcb:17
Stack trace:
#0 {main}
thrown in /in/3NKcb on line 17
Process exited with code 255.
Output for 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Call to undefined function openssl_pkey_get_private() in /in/3NKcb on line 17
Process exited with code 255.