Encrypts a file only with a passphrase.
The same passphrase is used to decrypt the file.
Equivalent GnuPG command:
gpg -c -e [dataFileName]
Namespace: DidiSoft.PgpThe same passphrase is used to decrypt the file.
Equivalent GnuPG command:
gpg -c -e [dataFileName]
Assembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public void EncryptFilePBE( FileInfo dataFile, string passphrase, FileInfo outputFile, bool asciiArmor ) |
| Visual Basic |
|---|
Public Sub EncryptFilePBE ( _ dataFile As FileInfo, _ passphrase As String, _ outputFile As FileInfo, _ asciiArmor As Boolean _ ) |
| Visual C++ |
|---|
public: void EncryptFilePBE( FileInfo^ dataFile, String^ passphrase, FileInfo^ outputFile, bool asciiArmor ) |
Parameters
- dataFile
- Type: System.IO..::..FileInfo
File to be encrypted
- passphrase
- Type: System..::..String
Passphrase used to encrypt the file
- outputFile
- Type: System.IO..::..FileInfo
File of the output encrypted file
- asciiArmor
- Type: System..::..Boolean
Should file be in ASCII armored format
Examples
This example shows how to encrypt a file only with a password.
CopyC#
CopyVB.NET
using System.IO; using DidiSoft.Pgp; class EncryptPasswordBasedDemo { public void Demo() { PGPLib pgp = new PGPLib(); bool asciiArmor = true; pgp.EncryptFilePBE(new FileInfo(@"DataFiles\INPUT.txt"), "password", new FileInfo(@"DataFiles\OUTPUT.pgp"), asciiArmor); } }
Imports System.IO Imports DidiSoft.Pgp Class EncryptPasswordBasedDemo Public Sub Demo() Dim pgp As New PGPLib() Dim asciiArmor As Boolean = True pgp.EncryptFilePBE(New FileInfo("DataFiles\INPUT.txt"), _ "password", _ New FileInfo("DataFiles\OUTPUT.pgp"), _ asciiArmor) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| DidiSoft.Pgp..::..PGPException | if an OpenPGP related error has occurred |
| DidiSoft.Pgp..::..PGPException | General encryption error |
| System.IO..::..IOException | I/O error |