comparison roundup/roundupdb.py @ 5494:b7fa56ced601

use gpg module instead of pyme module for PGP encryption
author Christof Meerwald <cmeerw@cmeerw.org>
date Sun, 12 Aug 2018 16:17:14 +0100
parents 725266c03eab
children f3d68c1bb96e
comparison
equal deleted inserted replaced
5493:725266c03eab 5494:b7fa56ced601
40 40
41 from roundup.anypy.strings import b2s, s2u 41 from roundup.anypy.strings import b2s, s2u
42 import roundup.anypy.random_ as random_ 42 import roundup.anypy.random_ as random_
43 43
44 try: 44 try:
45 import pyme, pyme.core 45 import gpg, gpg.core
46 # gpgme_check_version() must have been called once in a programm
47 # to initialise some subsystems of gpgme.
48 # See the gpgme documentation (at least from v1.1.6 to 1.3.1, e.g.
49 # http://gnupg.org/documentation/manuals/gpgme/Library-Version-Check.html)
50 # This is not done by pyme (at least v0.7.0 - 0.8.1). So we do it here.
51 # FIXME: Make sure it is done only once (the gpgme documentation does
52 # not tell if calling this several times has drawbacks).
53 pyme.core.check_version(None)
54 except ImportError: 46 except ImportError:
55 pyme = None 47 gpg = None
56 48
57 49
58 class Database: 50 class Database:
59 51
60 # remember the journal uid for the current journaltag so that: 52 # remember the journal uid for the current journaltag so that:
372 364
373 def encrypt_to(self, message, sendto): 365 def encrypt_to(self, message, sendto):
374 """ Encrypt given message to sendto receivers. 366 """ Encrypt given message to sendto receivers.
375 Returns a new RFC 3156 conforming message. 367 Returns a new RFC 3156 conforming message.
376 """ 368 """
377 plain = pyme.core.Data(message.as_string()) 369 plain = gpg.core.Data(message.as_string())
378 cipher = pyme.core.Data() 370 cipher = gpg.core.Data()
379 ctx = pyme.core.Context() 371 ctx = gpg.core.Context()
380 ctx.set_armor(1) 372 ctx.set_armor(1)
381 keys = [] 373 keys = []
382 for adr in sendto: 374 for adr in sendto:
383 ctx.op_keylist_start(adr, 0) 375 ctx.op_keylist_start(adr, 0)
384 # only first key per email 376 # only first key per email

Roundup Issue Tracker: http://roundup-tracker.org/