OpenSSL加密是可以的,但解密是错误的

first, im sorry for my bad English.

Im forced to use OpenSSL and im testing it now.

I have public key:

$key = "{key}"; 
$key = "-----BEGIN PUBLIC KEY-----
" . wordwrap($key, 64, "
", true) . "
-----END PUBLIC KEY-----";

When i use:

$secret = "test";
$test = openssl_public_encrypt($secret, $encrypted, $key);

... everything is ok, in $test is true - so encrypting is ok.

But now, i want decrypt it back, so i use:

$ok = openssl_public_decrypt($encrypted, $vys, $key);

...and on this place, the $ok variable contains false :( How it is possible?

Thanks very much to all!

You should decrypt with openssl_private_decrypt()
And you need to provide private key as argument.
Try to read more about public key encryption and openssl_public_encrypt