@
areless 感谢,我刚刚尝试这么做了
```PHP
function rsa_encode($data)
{
$public_key = "-----BEGIN PUBLIC KEY-----\n00b15fdee0d7ed06c21067d59e65031becca4c3eafe52d891725c75c37dac7ca2d\n-----END PUBLIC KEY-----";
$key = openssl_pkey_get_public ($rsa_public);
$result = str_split ($data , 117);
$str = '';
foreach ($result as $v) {
openssl_public_encrypt ($v , $crypted , $key);
$str .= $crypted;
}
if (! $str) {
throw new \Exception ('Failded RSA Check');
}
}
```
但是它提示
```
Warning: openssl_public_encrypt(): key parameter is not a valid public key in /demo/rsa.php on line 12
Fatal error: Uncaught Exception: Failded RSA Check in /demo/rsa.php:16 Stack trace: #0 /demo/rsa.php(38): rsa_encode() #1 {main} thrown in /demo/rsa.php on line 16
```