OpenPGP encrypts given file using the first available public PGP 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( string dataFile, string publicKeyFile, string outputFile, bool asciiArmor ) |
| Visual Basic |
|---|
Public Sub EncryptFile ( _ dataFile As String, _ publicKeyFile As String, _ outputFile As String, _ asciiArmor As Boolean _ ) |
| Visual C++ |
|---|
public: void EncryptFile( String^ dataFile, String^ publicKeyFile, String^ outputFile, bool asciiArmor ) |
Parameters
- dataFile
- Type: System..::..String
File to be encrypted
- publicKeyFile
- Type: System..::..String
Recipient public key file
- outputFile
- Type: System..::..String
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(); string inputFile = @"DataFiles\INPUT.txt"; string publicKey = @"DataFiles\public.asc"; string encryptedFile = @"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 String = "DataFiles\INPUT.txt" Dim publicKey As String = "DataFiles\public.asc" Dim encryptedFile As String = "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 |