这是我的 php 脚本
<?php
$pubfile = fopen("public_key.pem", "r");
$public = fread($pubfile, 8192);
fclose($pubfile);
openssl_get_publickey($public);
$prifile = fopen("private_key.pem", "r");
$private = fread($prifile, 8192);
fclose($prifile);
openssl_get_privatekey($private);
$plaintext = "hello";
openssl_public_encrypt ($plaintext , $crypted , $public);
openssl_private_decrypt($crypted, $decrypted, $private);
echo $decrypted;
?>
我各自的公钥和私钥
private_key.pem
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAtwxvPpbvbeJCztWlQCC0w2mQTNICarpIkbFTzlEooXA8Zo30
sN9cdH0Ifa/pIhfx0Lbm+e03Fz5NZelJZ5QRiRfoN9tcb5zYrwvVWx1SR6Zo5moS
S5YEvVSWVpu3D7x3IO2XVtTHlWTTRZk2c+ZuFR3eIwDZbmuOiTmuJMQCJiRd8pqf
4sVCoKzWrUmBuT2pc/sdUQ4IPylGK3yGVyxHNa8gCkBs/zVq3I0Zu7Nx8mW8DTn9
EvP02mkFHynJZgKE0SJftu6Mp9BDl4qR4T8896K+Z1Fi3qx3iK6nkjYjXCYYZB90
6uWiqm7BK/4zbzuc604+BZ4LOPgCsO+aZjx3ywIDAQABAoIBABgTfp5Q4/UkCX2D
BFVG9/+r5trz1HWNQvZGyKseaaWySX+DtGd/OX3o5DED7joZxCibpg3BcbmQ7EU3
RfxlsVjC2DxgkevsSWPcvpdZZ/UcojeMRBPFC6KLeaqymIVtWI3wMjOtkQLJXDCP
UmY0LM6COzGHbxHi+8B44brcPRwe+zJK5ALhPfFEyPsnz9Rw2PLBWceXNeZYN0ja
C699r+a/t0kdJ0+49LLTvFjFECZLArZTK1GZbzACeM/fFl7XvK3tsdAkizys0Dwl
eyDtINkWlg+hzt8uijVY78MvP36RM8k4QIjSX/2p/jupsyZD4I2R9OW+ml9sImok
Ud5YKaECgYEA7xbLLvZ5ddpf/yBSVpGytfU/PzWK5L9cPRbrQPll6iKgimAOTULi
VQAQYaCDL/er/zjVU+a2Kxv1G8y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8XBNyRimvypxaPhcEiQYFlirVq
/jvyUaJg01VjXxp1PKqXwIurF+Eu+W6b4OotLHY0EAPckNiP4XOHMNWd/NG5jV3F
mEzz5Cn9IdMDHSewcA6/rsOqVx0bZOBnSsmVLu9fPsCyrs7eBSXZSlIFKHD39HR6
eQIDAQAB
-----END PUBLIC KEY-----
$crypted
将加密数据返回给我,但解密没有回应。
NULL
我对结果做了一个回应,它作为任何想法回来了?