Crypt_GPG debugging process

Source: Internet
Author: User
Tags crypt
: This article describes how to debug Crypt_GPG. For more information about PHP tutorials, see. Error output on the browser:

( ! ) Fatal error: Uncaught 
  
   
    Crypt_GPG_FileException: 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 
    /usr/local/webdata/andy/fanli/citic/Crypt/GPGAbstract.php on line 
    278
    
     Exception trace
     
      #
      
       Function
       
        Location
        
         0Crypt_GPG_Engine->__construct(Array)/usr/local/webdata/andy/fanli/citic/Crypt/GPGAbstract.php in /usr/local/webdata/andy/fanli/citic/Crypt/GPG/Engine.php on line 541
        
       
      
     
    
   
  

Error message output by the command line:

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

The first error reported in browser is my analysis of permission issues, and the second is the true problem when running in shell. use brew to install gpg-agent as prompted.

Then I write the code as follows:

require_once'./Crypt/GPG.php';$gpg = new Crypt_GPG();$key = getKey();$gpg->addDecryptKey('zhangsanfeng','123456');$encrypted = file_get_contents('wait_for_decrpyt.txt.gpg');$data = $gpg->decrypt($encrypted);echo'
';var_dump($data);exit;

The decryption is successful !!!

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above describes the process of debugging Crypt_GPG, including the content, and hope to be helpful to friends who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.