OpenPGP encrypts given file using the first available public OpenPGP key from a key ring file
Namespace: DidiSoft.PgpAssembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public void EncryptFile( FileInfo dataFile, FileInfo publicKeyFile, FileInfo outputFile, bool asciiArmor ) |
| Visual Basic |
|---|
Public Sub EncryptFile ( _ dataFile As FileInfo, _ publicKeyFile As FileInfo, _ outputFile As FileInfo, _ asciiArmor As Boolean _ ) |
| Visual C++ |
|---|
public: void EncryptFile( FileInfo^ dataFile, FileInfo^ publicKeyFile, FileInfo^ outputFile, bool asciiArmor ) |
Parameters
- dataFile
- Type: System.IO..::..FileInfo
File to be encrypted
- publicKeyFile
- Type: System.IO..::..FileInfo
Recipient public key file
- outputFile
- Type: System.IO..::..FileInfo
Output encrypted file
- asciiArmor
- Type: System..::..Boolean
If true the encrypted file will be in ASCII armored format, otherwise in binary format
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(); FileInfo inputFile = new FileInfo(@"DataFiles\INPUT.txt"); FileInfo publicKey = new FileInfo(@"DataFiles\public.asc"); FileInfo encryptedFile = new FileInfo(@"DataFiles\OUTPUT.pgp"); bool asciiArmor = true; pgp.EncryptFile(inputFile, publicKey, encryptedFile, asciiArmor); } }
Imports System.IO Imports DidiSoft.Pgp Class EncryptDemo Public Sub Demo() Dim pgp As New PGPLib() Dim inputFile As New FileInfo("DataFiles\INPUT.txt") Dim publicKey As New FileInfo("DataFiles\public.asc") Dim encryptedFile As New FileInfo("DataFiles\OUTPUT.pgp") Dim asciiArmor As Boolean = True pgp.EncryptFile(inputFile, publicKey, encryptedFile, asciiArmor) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| DidiSoft.Pgp.Exceptions..::..WrongPublicKeyException | If the supplied public key file is not usable |
| DidiSoft.Pgp..::..PGPException | if an OpenPGP related error has occurred |
| System.IO..::..IOException | I/O error |