aboutsummaryrefslogtreecommitdiffstats
path: root/python/test_gpg.py
blob: 2b346559d0b3101398718a85e10491a272d9109e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gpg
from serenitas.utils.exchange import ExchangeMessage


em = ExchangeMessage()
for msg in em.get_msgs(path=["SeleneOps", "Passport"]):
    for attach in msg.attachments:
        if attach.name == "Attachment1.pgp":
            try:
                with attach.fp as fp:
                    plaintext, result, verify_result = gpg.Context().decrypt(
                        fp.read(), passphrase="Serenitas1"
                    )
            except gpg.errors.GPGMEError as e:
                print(e)