PGP Encrypts given file using Public key from a Key store.
If more than one key exists with the specified userId, the first one is used.

Namespace:  DidiSoft
Assembly:  PGPLib (in PGPLib.dll) Version: 1.6.3.19546

Syntax

C#
public void EncryptFile(
	string dataFileName,
	KeyStore keyStore,
	string userId,
	string outputFileName,
	bool asciiArmor,
	bool withIntegrityCheck
)
Visual Basic (Declaration)
Public Sub EncryptFile ( _
	dataFileName As String, _
	keyStore As KeyStore, _
	userId As String, _
	outputFileName As String, _
	asciiArmor As Boolean, _
	withIntegrityCheck As Boolean _
)
Visual C++
public:
void EncryptFile(
	String^ dataFileName, 
	KeyStore^ keyStore, 
	String^ userId, 
	String^ outputFileName, 
	bool asciiArmor, 
	bool withIntegrityCheck
)

Parameters

dataFileName
Type: System..::.String
File name to be encrypted (absolute or relative path)
keyStore
Type: DidiSoft..::.KeyStore
KeyStore instance
userId
Type: System..::.String
User Id of the form "name (comment) <email address>". The first Public key with this userId located in keyStore is used for encryption.
outputFileName
Type: System..::.String
File name of the Output encrypted file (absolute or relative path)
asciiArmor
Type: System..::.Boolean
Should the encrypted file be in ASCII Armored mode. 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;
   using DidiSoft;

   public class KeyStoreEncryptFile
   {
     public static void Demo()
     {
        KeyStore keyStore = new KeyStore(@"DataFiles\key.store", "changeit");
        PGPLib pgp = new PGPLib();

        String publicKeyUserId = "support@didisoft.com";
        bool asciiArmor = false; // binary output
        bool integrityCheck = false; // no integrity check
        pgp.EncryptFile(@"DataFiles\INPUT.txt", 
                        keyStore, 
                        publicKeyUserId, 
                        @"DataFiles\OUTPUT.pgp", 
                        asciiArmor, 
                        integrityCheck);            
     }
}
CopyVB.NET
Imports System
Imports DidiSoft

   Public Class KeyStoreEncryptFile
       Public Shared Sub Demo()
           Dim keyStore As New KeyStore("DataFiles\key.store", "changeit")
           Dim pgp As New PGPLib()

           Dim publicKeyUserId As String = "support@didisoft.com"
           Dim asciiArmor As Boolean = False ' binary output
           Dim integrityCheck As Boolean = False ' no integrity check
           pgp.EncryptFile("DataFiles\INPUT.txt", _
                           keyStore, _
                           publicKeyUserId, _
                           "DataFiles\OUTPUT.pgp", _
                           asciiArmor, _
                           integrityCheck)
       End Sub
   End Class

Exceptions

ExceptionCondition
PgpExceptionif no public key exists with the specified keyId

See Also