3 # Copyright (C) 2016 g10 Code GmbH
4 # Copyright (C) 2005 Igor Belyi <belyi@users.sourceforge.net>
5 # Copyright (C) 2002 John Goerzen <jgoerzen@complete.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, see <http://www.gnu.org/licenses/>.
20 from __future__ import absolute_import, print_function, unicode_literals
21 del absolute_import, print_function, unicode_literals
26 with gpg.Context(armor=True) as c:
28 print("Enter name of your recipient(s), end with a blank line.")
33 new = list(c.keylist(line))
35 print("Matched no known keys.")
37 print("Adding {}.".format(", ".join(k.uids[0].name for k in new)))
38 recipients.extend(new)
41 sys.exit("No recipients.")
43 print("Encrypting for {}.".format(", ".join(k.uids[0].name
44 for k in recipients)))
46 ciphertext, _, _ = c.encrypt(b"This is my message,", recipients)
47 sys.stdout.buffer.write(ciphertext)