Protect multiple files into one OpenPGP file
With OpenPGPBlackbox you can put several files in one OpenPGP archive. All such files will be glued together and protected in the same way (i.e. encrypted or signed).
Note. Technologically, OpenPGP works with opaque streams of data. The standard itself does not provide means for placing several objects to the same OpenPGP file - basically, every OpenPGP implementation takes a stream on input and produces a protected stream on output. The functionality of putting multiple files into a single OpenPGP archive is reached by employing TAR format to concatenate all source files into a single stream and then feeding the resulting glued stream to the OpenPGP engine. While this is a de-facto standard employed by the majority of OpenPGP implementations, it is not standardised de-jure, and thus applications have no obligation to support it and some of them might not.
When encrypting/signing multiple files you configure your TElPGPWriter in exactly same way as you do when encrypting/signing a single input file. To find out more about configuring your component, respectively, for encryption and signing, read about encrypting a file and signing a file.
The only difference from the single-file routine is the method that you call. This is EncryptFiles() for encryption case, SignFiles() for signing case, and EncryptAndSignFiles() for encryption-and-signing case. The methods are ready to take either file paths or streams, should you want to provide your own sources for the input and output files, or use the local file system. Use 'null' values if you don't want to use streams.
TElStringList filenames = new TElStringList(); filenames.Add(@”C:\Files\picture1.png”); filenames.Add(@”C:\Files\picture2.png”); filenames.Add(@”C:\Files\picture3.png”); pgpWriter.EncryptFiles(filenames, null, “pictures.pgp”, null);If you want to use streams, then filenames list would contain just names for the streams in the resulting OpenPGP file, and the data won't be read from the actual files on the disks (provided streams will be used instead).