[[!meta title="pgp-mime"]] [[!template id=gitrepo repo=pgp-mime]] [[!meta date="2009-02-04 11:39:37"]] I've been scripting up a few things recently and my inability to send nicely formatted [[OpenPGP|PGP]] messages was starting to really bug me. I had been encrypting my logwatch output with `gpg` and just emailing the raw `gpg` output to myself, but it's annoying to have to ESC-P every time I want to decrypt a log. The tipping point came while I was writing up a script to automatically email grades out to my students (not that any of the student's care about PGP, but it's the principle of the thing ;), since there's no way I'm going to send them raw gpg output (they would die) and there's also no way I'm going to hold Mutt's hand while it signs the emails. I dunno why Mutt doesn't have some `--batch` mode options to support PGP, but there it is. Pgp-mime is my home-grown solution. It's not very complicated really, just implementing the [RFC 3156][] specs in [[Python]]. It's been through a number of iterations over the years, and now (2012) I think the interface has matured to the point of actually being useful to other people as well ;). While there are [some other GnuPG wrappers][wrappers] for Python, my wrappers are the only ones using [the Assuan protocol][assuan] (via my [[pyassuan]]) to communicate with [gpgme-tool][]. All the other interfaces spawn `gpg` directly (e.g. using the [subprocess][] module), and scrape its output, which is not ideal. Pgp-mime still uses `subprocess` to spawn `gpgme-tool`, but I'm currently working with the GnuPG folks to get a proper socket interface which would put `gpgme-tool` on par with `gpg-agent`. Then pgp-mime could drop all the `subprocess` stuff, which would make things more robust. I'm also waiting on Python 3.3 to get support for [sendmsg][] and [recvmsg][] in Python's [socket][] module, which would allow me to pass file descriptors to a persistent, external `gpgme-tool`. The `README` is posted on the [PyPI page][pypi]. [[Email me|contact]] with (encrypted!) feedback. [RFC 3156]: http://www.ietf.org/rfc/rfc3156.txt [pypi]: http://pypi.python.org/pypi/pgp-mime/ [wrappers]: http://wiki.python.org/moin/GnuPrivacyGuard [assuan]: http://www.gnupg.org/documentation/manuals/assuan/ [gpgme-tool]: http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gpgme.git;a=blob;f=src/gpgme-tool.c;hb=HEAD [subprocess]: http://docs.python.org/library/subprocess.html [sendmsg]: http://docs.python.org/dev/library/socket.html#socket.socket.sendmsg [recvmsg]: http://docs.python.org/dev/library/socket.html#socket.socket.recvmsg [socket]: http://docs.python.org/dev/library/socket.html [[!tag tags/code]] [[!tag tags/linux]] [[!tag tags/programming]] [[!tag tags/pypi]] [[!tag tags/python]]