Encrypts multiple files into a single OpenPGP archive, using one ore more recipient public keys.

Namespace: DidiSoft.Pgp
Assembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547

Syntax

C#
public void EncryptFiles(
	string[] dataFiles,
	string[] publicKeyFiles,
	string outputFileName,
	bool asciiArmor,
	bool withIntegrityCheck
)
Visual Basic
Public Sub EncryptFiles ( _
	dataFiles As String(), _
	publicKeyFiles As String(), _
	outputFileName As String, _
	asciiArmor As Boolean, _
	withIntegrityCheck As Boolean _
)
Visual C++
public:
void EncryptFiles(
	array<String^>^ dataFiles, 
	array<String^>^ publicKeyFiles, 
	String^ outputFileName, 
	bool asciiArmor, 
	bool withIntegrityCheck
)

Parameters

dataFiles
Type: array<System..::..String>[]()[][]
File(s) to be encrypted (absolute or relative path)
publicKeyFiles
Type: array<System..::..String>[]()[][]
Public key ring file(s) (absolute or relative path)
outputFileName
Type: System..::..String
Output encrypted file name(absolute or relative path)
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

Examples

CopyC#
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
        string[] inputFiles =
           new string[] {@"c:\file1.txt",
                         @"c:\file2.dat",
                         @"c:\file3.xls"};

        // one or more public keys to encrypt with
        string[] recipientPublicKeys =
           new string[] {@"c:\recipient_1_key.asc", 
                         @"c:\recipient_2_key.asc", 
                         @"c:\recipient_3_key.asc"};

        // encryption output
       string encryptedOutputFile = @"c:\OUTPUT.pgp";

        pgp.EncryptFiles(inputFiles,
                         recipientPublicKeys,
                         encryptedOutputFile, 
                         asciiArmor, 
                         withIntegrityCheck);    
    }
}
CopyVB.NET
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 String() = _
           New String() {"c:\file1.txt", _
                         "c:\file2.dat", _
                         "c:\file3.xls"}

        '-- one or more public keys to encrypt with
        Dim recipientPublicKeys As String() = _
           New String() {"c:\recipient_1_key.asc", _
                         "c:\recipient_2_key.asc", _
                         "c:\recipient_3_key.asc"}

        '-- encryption output
       Dim encryptedOutputFile As String = "c:\OUTPUT.pgp"

        pgp.EncryptFiles(inputFiles, _
                        recipientPublicKeys, _
                        encryptedOutputFile, _
                        asciiArmor, _
                        withIntegrityCheck)
    End Sub
End Class

Exceptions

ExceptionCondition
DidiSoft.Pgp..::..PGPExceptionif an OpenPGP related error has occurred
System..::..ArgumentExceptionIf the array with files to be encrypted is empty
DidiSoft.Pgp.Exceptions..::..WrongPublicKeyExceptionIf one of the supplied public keys is not usable
DidiSoft.Pgp..::..PGPExceptionGeneral encryption error
System.IO..::..IOExceptionI/O error

See Also