- General information
- Accessing GnuPG via gpgme
- Running gpg executables
- Related OpenPGP crypto not using GnuPG at all
GNU Privacy Guard is a Free Software GNU GPLed implementation of the crypto standards OpenPGP and CMS (used by S/MIME). Also known as "GnuPG" or "GPG". There are several principle ways to access GnuPG functions from Python: 1. use the official GPGME library or do something more low level like 2. run the gpg commands and pipe to them. The GnuPG initiative recommends using GPGME because it provides a documented API.
Accessing GnuPG via gpgme
pygpgme exposes the gpgme library to Python. The product was started by James Henstridge. Beside Python2 it supports Python 3 since v0.3 (March 2012). The wrapping is done using python's C interface directly without using a generator tool like SWIG.
PyMe Python interface to GPGME
GPGME is a library designed to make access to GnuPG easier for applications. It provides a high-level cryptography API for encryption, decryption, signing, signature verification, and key management. It currently uses GnuPG as its backend, but the API is not restricted to this engine. In fact, support for other backends is planned.
PyMe's development model is GPGME + Python + SWIG (just like m2crypto is an OpenSSL + Python + SWIG) combination which means that most of the functions and types are converted from C into Python automatically by SWIG. In short, to be able to use PyMe you need to be familiar with GPGME.
pgp-mime (using the assuan protocol to gpgme-tool)
pgp-mime makes it easy to construct, verify, and send signed and/or encrypted email. It uses a pyassuan-based connection to gpgme-tool for the cryptography, which is isolated in a pgp_mime.crypt module if you don't need the extra email-handling functionality. This currently uses gpgme by running gpgme-tool via subprocess. However, I'm working on turning gpgme-tool into a stand-alone server (similar to gpg-agent), after which users will be free to substitute other servers providing the gpgme-tool interface.
Running gpg executables
Python/GnuPG interface (old)
The original Python/GnuPG interface is no longer actively maintained by amk. Please record comments, recipes, and patches on this Wiki page. If anyone wants to maintain the module and needs a CVS repository to store the code, just ask for write permission to the pycrypto project on SourceForge.
GPG.py (2005, SteveTraugott, pipes)
I've added a great deal to amk's GPG.py, building on Richard Jones' 1.3 update and adding more support for the decryption, signing, key management, bells, whistles, and so on which amk's original design implied. This is still a pure-python implementation, and requires nothing that is not in Python 2.2.1 or later, other than the gpg executable itself. This is *not* a drop-in replacement; I needed to make some interface changes to support decryption and to better abstract the internals of returned objects -- it might want to be called GPG2.py (or maybe something like GPGng.py to prevent confusion with anything related to gnupg version 2 -- ideas welcome, as well as opinions on whether the name needs to be changed in the first place).
I don't know yet where the new module's permanent home is going to be, but as of this writing (July 2005) you can find it in the ISconf SVN Repository at http://trac.t7a.org/isconf/file/trunk/lib/python/isconf/GPG.py. The right thing for me (or someone) to do going forward will be to confirm the license with amk and/or re-publish under the GPL, and post it somewhere more permanent. If you do any of this before I get to it, then please update this page. -- SteveTraugott
python-gnupg (using pipes via subprocess)
Just four years on (July 2009) from Steve Traugott's sterling work mentioned above, I've updated the module (now called gnupg.py to avoid confusion) and made it available (under the New BSD License) at http://code.google.com/p/python-gnupg/ - it uses the subprocess module and so is easiest to use under Pythons >= 2.4. A unittest harness is also included.
GnuPGInterface is a Python module to interface with GnuPG. (This is a different project than the one mentioned above.) It concentrates on interacting with GnuPG via filehandles, providing access to control GnuPG via versatile and extensible means.
This module is based on GnuPG::Interface, a Perl module by the same author. Unfortunately, like the related Perl module it is not very easy to use.
Related OpenPGP crypto not using GnuPG at all
openpgp (2005, OpenPGP reimplementation)