Maison > développement back-end > tutoriel php > 调试Crypt_GPG的过程

调试Crypt_GPG的过程

WBOY
Libérer: 2016-07-29 09:15:51
original
1146 Les gens l'ont consulté

在浏览器端的错误输出信息:

<code>( ! ) Fatal error: Uncaught <span>table</span><span>style</span>=<span>"border: 1px"</span><span>cellspacing</span>=<span>"0"</span>><span>tr</span>><span>td</span><span>colspan</span>=<span>"3"</span><span>style</span>=<span>"background: #ff9999"</span>><span>b</span>>Crypt_GPG_FileException<span><span>b</span>></span>: The 'homedir' "/Library/WebServer/.gnupg" is not readable or does not exist and cannot be created. This can happen if 'homedir' is not specified in the Crypt_GPG options, Crypt_GPG is run as the web user, and the web user has no home directory. in <span>b</span>>/usr/local/webdata/andy/fanli/citic/Crypt/GPGAbstract.php<span><span>b</span>></span> on line <span>b</span>>278<span><span>b</span>></span><span><span>td</span>></span><span><span>tr</span>></span><span>tr</span>><span>td</span><span>colspan</span>=<span>"3"</span><span>style</span>=<span>"background-color: #aaaaaa; text-align: center; font-weight: bold;"</span>>Exception trace<span><span>td</span>></span><span><span>tr</span>></span><span>tr</span>><span>td</span><span>style</span>=<span>"text-align: center; background: #cccccc; width:20px; font-weight: bold;"</span>>#<span><span>td</span>></span><span>td</span><span>style</span>=<span>"text-align: center; background: #cccccc; font-weight: bold;"</span>>Function<span><span>td</span>></span><span>td</span><span>style</span>=<span>"text-align: center; background: #cccccc; font-weight: bold;"</span>>Location<span><span>td</span>></span><span><span>tr</span>></span><span>tr</span>><span>td</span><span>style</span>=<span>"text-align: center;"</span>>0<span><span>td</span>></span><span>td</span>>Crypt_GPG_Engine->__construct(Array)<span><span>td</span>></span><span>td</span>>/usr/local/webdata/andy/fanli/citic/Crypt/GPGAbstract.php in /usr/local/webdata/andy/fanli/citic/Crypt/GPG/Engine.php on line 541</code>
Copier après la connexion

命令行输出的错误信息:

<code>PHP Fatal error:  Uncaught PEAR_Exception: gpg<span>-agent</span> binary <span>not</span> found<span>.</span><span>If</span> you are sure the gpg<span>-agent</span> is installed, please specify the location of the gpg<span>-agent</span> binary using the <span>'agent'</span> driver option<span>.</span><span>in</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPGAbstract<span>.</span>php <span>on</span> line <span>278</span><span>#0</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPGAbstract<span>.</span>php(<span>278</span>): Crypt_GPG_Engine<span>-></span>__construct(<span>Array</span>)
<span>#1</span> /usr/<span>local</span>/webdata/andy/fanli/citic/gpg2<span>.</span>php(<span>9</span>): Crypt_GPGAbstract<span>-></span>__construct()
<span>#2</span> {main}
  thrown <span>in</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPG/Engine<span>.</span>php <span>on</span> line <span>601</span>Fatal error: Uncaught PEAR_Exception: gpg<span>-agent</span> binary <span>not</span> found<span>.</span><span>If</span> you are sure the gpg<span>-agent</span> is installed, please specify the location of the gpg<span>-agent</span> binary using the <span>'agent'</span> driver option<span>.</span><span>in</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPGAbstract<span>.</span>php <span>on</span> line <span>278</span><span>#0</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPGAbstract<span>.</span>php(<span>278</span>): Crypt_GPG_Engine<span>-></span>__construct(<span>Array</span>)
<span>#1</span> /usr/<span>local</span>/webdata/andy/fanli/citic/gpg2<span>.</span>php(<span>9</span>): Crypt_GPGAbstract<span>-></span>__construct()
<span>#2</span> {main}
  thrown <span>in</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPG/Engine<span>.</span>php <span>on</span> line <span>601</span></code>
Copier après la connexion

第一个browser中报的错我分析是权限问题,第二个在shell中运行才是其真正的问题所在,根据提示,使用brew安装gpg-agent。

之后我编写代码如下:

<code><span>require_once</span><span>'./Crypt/GPG.php'</span>;

<span>$gpg</span> = <span>new</span> Crypt_GPG();
<span>$key</span> = getKey();
<span>$gpg</span>->addDecryptKey(<span>'zhangsanfeng'</span>,<span>'123456'</span>);
<span>$encrypted</span> = file_get_contents(<span>'wait_for_decrpyt.txt.gpg'</span>);
<span>$data</span> = <span>$gpg</span>->decrypt(<span>$encrypted</span>);
<span>echo</span><span>'<pre class="brush:php;toolbar:false">'
Copier après la connexion
;var_dump($data);exit;

终于解密成功!!!

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了调试Crypt_GPG的过程,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal