【发布时间】:2013-08-22 21:32:45
【问题描述】:
我正在使用 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;
【问题讨论】:
-
您收到 webapp 或命令行的错误? (相关及为什么我问:Composer Warning: openssl extension is missing. How to enable in WAMP)
标签: php wamp php-openssl