Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpg.encrypt should be able to take a list of recipients #23

Closed
Hainish opened this issue Oct 14, 2013 · 2 comments
Closed

gpg.encrypt should be able to take a list of recipients #23

Hainish opened this issue Oct 14, 2013 · 2 comments

Comments

@Hainish
Copy link

Hainish commented Oct 14, 2013

In the docs, encrypt can take a list of recipients. This results in an error when actually used:

>>> x = gpg.encrypt('testing',['D3366755'])
>>> x.ok
False
>>> x.stderr
u'gpg: WARNING: "--no-use-agent" is an obsolete option - it has no effect\ngpg: Sorry, no terminal at all requested - can\'t get input\n'
@isislovecruft
Copy link
Owner

@Hainish Oh... the docs shouldn't say that. Do you remember where in the docs you saw this?

The encrypt method can take multiple recipients, just not in a list. The first parameter should be the data to encrypt, and all the rest of the non-keyword parameters should be interpreted as *recipients:

Type:       instancemethod
String Form:<bound method GPG.encrypt of <gnupg.gnupg.GPG object at 0x7f424c1375d0>>
File:       ../python-gnupg/gnupg/gnupg.py
Definition: g.encrypt(self, data, *recipients, **kwargs)
Docstring:
Encrypt the message contained in ``data`` to ``recipients``.

:param str data: The file or bytestream to encrypt.

:param str recipients: The recipients to encrypt to. Recipients must
    be specified keyID/fingerprint. Care should be taken in Python2.x
    to make sure that the given fingerprint is in fact a string and
    not a unicode object.

:param str default_key: The keyID/fingerprint of the key to use for
    signing. If given, ``data`` will be encrypted and signed.

:param str passphrase: If given, and ``default_key`` is also given,
    use this passphrase to unlock the secret portion of the
    ``default_key`` to sign the encrypted ``data``. Otherwise, if
    ``default_key`` is not given, but ``symmetric=True``, then use
    this passphrase as the passphrase for symmetric
    encryption. Signing and symmetric encryption should *not* be
    combined when sending the ``data`` to other recipients, else the
    passphrase to the secret key would be shared with them.

:param bool armor: If True, ascii armor the output; otherwise, the
    output will be in binary format. (Default: True)

:param bool encrypt: If True, encrypt the ``data`` using the
    ``recipients`` public keys. (Default: True)

:param bool symmetric: If True, encrypt the ``data`` to ``recipients``
    using a symmetric key. See the ``passphrase`` parameter. Symmetric
    encryption and public key encryption can be used simultaneously,
    and will result in a ciphertext which is decryptable with either
    the symmetric ``passphrase`` or one of the corresponding private
    keys.

:param bool always_trust: If True, ignore trust warnings on recipient
    keys. If False, display trust warnings.  (default: True)

:param str output: The output file to write to. If not specified, the
    encrypted output is returned, and thus should be stored as an
    object in Python.

@isislovecruft
Copy link
Owner

Um… so either there was some confusion, or I had bad documentation that got fixed somewhere along the way, or there is actually some sort of problem here and I didn't understand what it was. But since this ticket has been open forever, no one else has complained about encrypt() not working for multiple recipients, and there are several unittests for encrypting to multiple recipients in all sorts of different ways, I am closing this ticket.

Please feel free to reopen if I've misunderstood something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants