我正在使用 WAMP 2.4.4。为了加密字符串,我使用了“ MyEncryption ”类,但错误是:
调用未定义函数 openssl_public_encrypt()
在使用之前我必须添加任何特殊的库吗openssl_public_encrypt()
class MyEncryption
{
public $pubkey = '...public key here...';
public $privkey = '...private key here...';
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;
}
}
$url = new MyEncryption();
$d = "Hello World";
$enc = $url->encrypt($d);
echo "Encryption is: ", $enc;