something like perl's Mail::GPG ?

Discussion in 'Python' started by akonsu, Aug 14, 2009.

  1. akonsu

    akonsu Guest

    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
     
    akonsu, Aug 14, 2009
    #1
    1. Advertising

  2. >>>>> akonsu <> (a) wrote:

    >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"

    --
    Piet van Oostrum <>
    URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
    Private email:
     
    Piet van Oostrum, Aug 14, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Will Hartung

    Java interacting with gpg

    Will Hartung, Feb 21, 2004, in forum: Java
    Replies:
    1
    Views:
    2,676
    Sudsy
    Feb 22, 2004
  2. Choo Zhi Min

    Cannot import Python 2.3.3 RPM GPG key

    Choo Zhi Min, May 11, 2004, in forum: Python
    Replies:
    1
    Views:
    519
    Paul Rubin
    May 11, 2004
  3. Alessandro Bottoni

    Decrypting GPG/PGP email messages

    Alessandro Bottoni, Sep 1, 2005, in forum: Python
    Replies:
    10
    Views:
    879
    Paul Rubin
    Sep 3, 2005
  4. Nomen Nescio

    Finding Return Code From GPG

    Nomen Nescio, Jul 4, 2006, in forum: Python
    Replies:
    5
    Views:
    1,078
    Nomen Nescio
    Jul 8, 2006
  5. Kai Schlamp

    automate gpg with perl

    Kai Schlamp, Feb 24, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    97
    Matthew Braid
    Feb 25, 2004
Loading...

Share This Page