我尝试了这个简单的代码:
<?php
$publicKey = openssl_pkey_get_public("public.pem");
$plaintext = "String to encrypt";
openssl_public_encrypt($plaintext, $encrypted, $publicKey);
echo $encrypted; //encrypted string
?>
但是我收到此错误消息。
警告:openssl_public_encrypt():key参数不是第6行的C:\ xampp \ htdocs \ encrypt \ encrypt_rsa.php中的有效公钥