我正在使用WAMP 2.4.4。要加密字符串我用「MyEncryption」級,但錯誤是:在PHP中調用未定義函數openssl_public_encrypt()
調用未定義功能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;
採取
回答您得到錯誤的web應用程序或命令行? (相關和爲什麼我問:[作曲家警告:缺少openssl擴展名。如何在WAMP中啓用](http://stackoverflow.com/q/14062055/367456)) – hakre