简体   繁体   中英

Bouncycastle PGP with multiple files

I am developing a tool to encrypt one or multiple files using PGP. So far, I had no problem to encrypt a single files. For encrypting several files, I had to resort to zip them in a single file, and then encrypt the single file. However, I know that Symantec PGP can encrypt several files inside one.PGP file, without having to zip multiple files. I think this is a more elegant solution, as one does not have to decrypt and unzip (two steps), but only open the PGP file and then select the files. I have only found examples to encrypt a single files, but no information on how to encrypt several ones. For the record, I am using BouncyCastle.

I fear there is no way around using ZIP compression before encrypting.

While you could use multiple Literal Data Packets (one per file) inside your message, section 11.3 of RFC4880 hints that there can only be a single Literal Data Packet per message. This is also the interpretation of the OpenPGP Interoperability Test Suite which shows that quite a bunch of implementations reject messages with more than one Literal Data Packet.

Going with ZIP is your best option here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM