Encrypts a file with a public key and a passphrase.
The passphrase can be used to decrypt the file if the corressponding private key is lost.

Example GnuPG command:
gpg -r [public key user id] -c -e [dataFileName]

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

Syntax

C#
public void EncryptFilePBE(
	string dataFileName,
	string publicKeyFileName,
	string passphrase,
	string outputFileName,
	bool asciiArmor,
	bool withIntegrityCheck
)
Visual Basic (Declaration)
Public Sub EncryptFilePBE ( _
	dataFileName As String, _
	publicKeyFileName As String, _
	passphrase As String, _
	outputFileName As String, _
	asciiArmor As Boolean, _
	withIntegrityCheck As Boolean _
)
Visual C++
public:
void EncryptFilePBE(
	String^ dataFileName, 
	String^ publicKeyFileName, 
	String^ passphrase, 
	String^ outputFileName, 
	bool asciiArmor, 
	bool withIntegrityCheck
)

Parameters

dataFileName
Type: System..::.String
File name to be encrypted (absolute or relative path)
publicKeyFileName
Type: System..::.String
Key ring file name (absolute or relative path)
passphrase
Type: System..::.String
Additional passphrase that can be used to decrypt the file instead of using the private key
outputFileName
Type: System..::.String
File name of the Output encrypted file (absolute or relative path)
asciiArmor
Type: System..::.Boolean
Should file be in ASCII Armored format
withIntegrityCheck
Type: System..::.Boolean
Should integrity check information be added to the file.

Examples

CopyC#
using System.IO;
using DidiSoft; 

class EncryptDemo {
  public void Demo() {
    PGPLib pgp = new PGPLib();
    bool asciiArmor = true;
    bool withIntegrityCheck = true;

    pgp.EncryptFilePBE(@"DataFiles\INPUT.txt",
                            @"DataFiles\public_key.asc",
                            "alternative_password",
                            @"DataFiles\OUTPUT.pgp", 
                            asciiArmor, 
                            withIntegrityCheck);    
 }
}
CopyVB.NET
Imports System.IO
Imports DidiSoft

Class EncryptDemo
 Public Sub Demo()
   Dim pgp As New PGPLib()
   Dim asciiArmor As Boolean = True
   Dim withIntegrityCheck As Boolean = False

        pgp.EncryptFilePBE("DataFiles\INPUT.txt", _
                            "DataFiles\public_key.asc", _
                             "alternative_password", _
                             "DataFiles\OUTPUT.pgp", _
                             asciiArmor, _
                             withIntegrityCheck)
  End Sub
End Class

Exceptions

ExceptionCondition
PgpExceptionif an error has occured

See Also