我看到了这段代码:
<?php
class MyEncryption
{
    public $pubkey = '...public key here...';
    public $privkey = '...private key here...';
    public function encrypt($data)
    {
        if (openssl_public_encrypt($data, $encrypted, $this->pubkey))
            $data = base64_encode($encrypted);
        else
            throw new Exception('Unable to encrypt data. Perhaps it is bigger than the key size?');
        return $data;
    }
    public function decrypt($data)
    {
        if (openssl_private_decrypt(base64_decode($data), $decrypted, $this->privkey))
            $data = $decrypted;
        else
            $data = '';
        return $data;
    }
}
?>
什么是 public_key 的样本?什么样的公钥应该放在 $pubkey 上?它应该是base_64编码还是不?如何生成一个?
我补充说:
$privKey = openssl_pkey_new();
我得到的只是 $privKey==false