something like perl's Mail::GPG ?

A

akonsu

hello,

i am looking for a module with functionality similar to that of the
Perl's Mail::GPG package. I need to verify multipart emails that are
PGP-signed.

thanks for any advice
konstantin
 
P

Piet van Oostrum

akonsu said:
a> hello,
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
a> PGP-signed.

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.
Example:

import os
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'))

if gpg.verify(cl):
print "Signature correct"
else:
print "Signature incorrect"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top