something like perl's Mail::GPG ?
Piet van Oostrum
piet at cs.uu.nl
Fri Aug 14 23:30:45 CEST 2009
>>>>> akonsu <akonsu at gmail.com> (a) wrote:
>a> i am looking for a module with functionality similar to that of the
>a> Perl's Mail::GPG package. I need to verify multipart emails that are
I don't know Perl's GPG package, but to verify PGP-signed stuff you can
use gnupg. It doesn't have special code for mail messages, however. It
is just a Pythonic wrapper facade around the gpg program.
However, it doesn't do the PGP/MIME stuff, so you will have to transform
the MIME messages into something that GPG understands. This isn't hard
and you can find a short python script that does it on
http://domnit.org/2008/03/clearmime. It describes how you can use it as
a program and pipe the message through it into gpg --verify. You can
also use it as a module if you rename it to clearmime.py, and use it
with the recently released gnupg module. It is released under GPL.
However it wouldn't be hard to write something similar yourself, for
example if you want to feed it existing Message objects rather than strings.
from gnupg import GPG
from clearmime import clarify
msgtxt = open('testgpg.msg').read()
cl = clarify(msgtxt)
gpg=GPG(gnupghome = os.path.join(os.environ['HOME'], '.gnupg'))
print "Signature correct"
print "Signature incorrect"
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list