Introduction and Overview


Crypt_GPG is a PHP package to interact with the GNU Privacy Guard (GnuPG). GnuPG is a free and open-source implementation of the OpenPGP protocol, providing key management, data encryption and data signing. Crypt_GPG provides an object-oriented API for performing OpenPGP actions using GnuPG.

GnuPG is distributed as an executable program with a command-line argument syntax for performing actions. Crypt_GPG uses PHP's program execution functions to run GnuPG as a subprocess, performing the desired action. Crypt_GPG automatically handles process control, stream handling and error checking of the GnuPG subprocess. Crypt_GPG uses PHP streams internally for most actions, allowing (among other things) any streamable resource to be used with the Crypt_GPG file commands.

Though GnuPG can support symmetric-key cryptography, this package is intended only to facilitate public-key cryptography.


The basic internal overview of a GnuPG command executed in Crypt_GPG is as follows:

  1. build the required command line,
  2. open the GnuPG subprocess with the command line,
  3. stream data to and from the GnuPG subprocess on various IPC pipes until the command is finished,
  4. close the GnuPG subprocess and,
  5. check for errors.

Crypt_GPG handles all these details internally so GnuPG can be used with minimal effort from the developer.

Crypt_GPG (Previous) Generating a GnuPG Key (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.