Encrypts multiple files into a single OpenPGP archive, using one ore more recipient public keys.
Namespace: DidiSoft.PgpAssembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public void EncryptFiles( FileInfo[] dataFiles, FileInfo[] publicKeyFiles, FileInfo outputFile, bool asciiArmor, bool withIntegrityCheck ) |
| Visual Basic |
|---|
Public Sub EncryptFiles ( _ dataFiles As FileInfo(), _ publicKeyFiles As FileInfo(), _ outputFile As FileInfo, _ asciiArmor As Boolean, _ withIntegrityCheck As Boolean _ ) |
| Visual C++ |
|---|
public: void EncryptFiles( array<FileInfo^>^ dataFiles, array<FileInfo^>^ publicKeyFiles, FileInfo^ outputFile, bool asciiArmor, bool withIntegrityCheck ) |
Parameters
- dataFiles
- Type: array<System.IO..::..FileInfo>[]()[][]
File(s) to be encrypted
- publicKeyFiles
- Type: array<System.IO..::..FileInfo>[]()[][]
Public key ring file(s)
- outputFile
- Type: System.IO..::..FileInfo
Output file (encrypted)
- asciiArmor
- Type: System..::..Boolean
Should the encrypted file be in ASCII Armored format. If false the encrypted file is in binary format.
- withIntegrityCheck
- Type: System..::..Boolean
Should integrity check information be added to the encrypted file.
Remarks
Compression algorithm used is the one specified through Compression
Symmetric cipher algorithm used is the one specified through Cypher
Symmetric cipher algorithm used is the one specified through Cypher
Examples
using System.IO; using DidiSoft.Pgp; class EncryptDemo { public void Demo() { PGPLib pgp = new PGPLib(); bool asciiArmor = true; bool withIntegrityCheck = true; // files to be encrypted FileInfo[] inputFiles = new FileInfo[] {new FileInfo(@"c:\file1.txt"), new FileInfo(@"c:\file2.dat"), new FileInfo(@"c:\file3.xls")}; // one or more public keys to encrypt with FileInfo[] recipientPublicKeys = new FileInfo[] {new FileInfo(@"c:\recipient_1_key.asc"), new FileInfo(@"c:\recipient_2_key.asc"), new FileInfo(@"c:\recipient_3_key.asc")}; // encryption output FileInfo encryptedOutputFile = new FileInfo(@"c:\OUTPUT.pgp"); pgp.EncryptFiles(inputFiles, recipientPublicKeys, encryptedOutputFile, asciiArmor, withIntegrityCheck); } }
Imports System.IO Imports DidiSoft.Pgp Class EncryptDemo Public Sub Demo() Dim pgp As New PGPLib() Dim asciiArmor As Boolean = True Dim withIntegrityCheck As Boolean = False '-- files to be encrypted Dim inputFiles As FileInfo() = _ New FileInfo() {New FileInfo("c:\file1.txt"), _ New FileInfo("c:\file2.dat"), _ New FileInfo("c:\file3.xls")} '-- one or more public keys to encrypt with Dim recipientPublicKeys As FileInfo() = _ New FileInfo() {New FileInfo("c:\recipient_1_key.asc"), _ New FileInfo("c:\recipient_2_key.asc"), _ New FileInfo("c:\recipient_3_key.asc")} '-- encryption output Dim encryptedOutputFile As New FileInfo("c:\OUTPUT.pgp") pgp.EncryptFiles(inputFiles, _ recipientPublicKeys, _ encryptedOutputFile, _ asciiArmor, _ withIntegrityCheck) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| DidiSoft.Pgp..::..PGPException | if an OpenPGP related error has occurred |
| System..::..ArgumentException | If the array with files to be encrypted is empty |
| DidiSoft.Pgp.Exceptions..::..WrongPublicKeyException | If one of the supplied public keys is not usable |
| DidiSoft.Pgp..::..PGPException | General encryption error |
| System.IO..::..IOException | I/O error |