【发布时间】:2013-12-24 11:40:11
【问题描述】:
我正在尝试使用托管在 Rackspace 上的 Linux 服务器上的 PHP GnuPG 库来加密字符串,但是无论我尝试什么,我都会不断收到错误消息。请看下面:
致命错误:在 /var/www/vhosts/royal/facebook/email-sign-up/encrypt.php:10 堆栈中未捕获的异常“异常”和消息“没有加密集的密钥”跟踪:#0 /var/www/vhosts/royal/facebook/email-sign-up/encrypt.php(10): gnupg->encrypt('this is some co...') #1 {main} throw in /var/www/vhosts/royal/facebook/email-sign-up/encrypt.php 在第 10 行
我已检查 GnuPG 库是否已正确安装在服务器上,我使用了正确的密钥指纹,并且服务器有权读取/写入 GNUPGHOME 目录。
请看下面我正在使用的 PHP 代码:
$gpg = new gnupg();
putenv("GNUPGHOME=/root/.gnupg");
$gpg->seterrormode(GNUPG_ERROR_SILENT);
$gpg->addencryptkey('********************************');
$gpg->seterrormode(gnupg::ERROR_EXCEPTION); // throw an exception in case of an error
$encrypted = $gpg->encrypt('this is some confidential information');
echo "Encrypted text: \n<pre>$encrypted</pre>\n";
感谢您的帮助,我们将不胜感激!
【问题讨论】: