neuhalje/bouncy-gpg

FR: Encrypt to multiple recipients + encrypt to self

iNPUTmice opened this issue · 4 comments

I have two feature request that could be combined into one.
First I would like to be able to encrypt to multiple user ids.
Second I would like to (optionally) also encrypt to myself. The second of course can be done with the first. But maybe it would be nicer to have it as a paramater in the fluid interface. like ….andEncryptToSelf() or something like that.

I could provide a PR if we can agree on the API. For the first feature i would let the toRecipient() just take String... instead of String and then feed a Collection into the EncryptionStream class.

Adding multiple recipients sounds like a good idea. I'd say to add toRecipients(String...) so that it is grammatically correct. I would keep toRecipient(String) in order to keep the API stable. The "duplication" (both toRecipient("test@example.com") and toRecipients("test@example.com") would work) is a non-issue to me.

...andEncryptToSelf() is more difficult as the API (KeyringConfig) currently has no concept of who "Self" might be.

OK. I'll try to create a PR on Monday.

Ping :-)

Implemented with e53d1d2:

final OutputStream outputStream = BouncyGPG
        .encryptToStream()
        .withConfig(...)
        .withAlgorithms(algorithmSuite)
        .toRecipients("recipient1@example.com", "recipient2@example.com")
        ...