Signs and encrypts a file in one pass, backward compatibile with PGP 6.5 and below
Namespace: DidiSoft.PgpAssembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public void SignAndEncryptFileV3( string inputFileName, string privateKeyFileName, string password, string publicKeyFileName, string outputFileName, bool asciiArmor ) |
| Visual Basic |
|---|
Public Sub SignAndEncryptFileV3 ( _ inputFileName As String, _ privateKeyFileName As String, _ password As String, _ publicKeyFileName As String, _ outputFileName As String, _ asciiArmor As Boolean _ ) |
| Visual C++ |
|---|
public: void SignAndEncryptFileV3( String^ inputFileName, String^ privateKeyFileName, String^ password, String^ publicKeyFileName, String^ outputFileName, bool asciiArmor ) |
Parameters
- inputFileName
- Type: System..::..String
File Name to be PGP signed and encrypted (absolute or relative path)
- privateKeyFileName
- Type: System..::..String
Private key file used for signing (absolute or relative path)
- password
- Type: System..::..String
Private key password
- publicKeyFileName
- Type: System..::..String
Public key file used for encryption (absolute or relative path)
- outputFileName
- Type: System..::..String
File name of the output encrypted file (absolute or relative path)
- asciiArmor
- Type: System..::..Boolean
if true, output file is in ASCII armored format
Remarks
* (Note that this is not the same as first encrypt and then sign a file, because in that case a double compression is performed.)
Compression algorithm used is the one specified through Compression
Symmetric cipher algorithm used is the one specified through Cypher
Compression algorithm used is the one specified through Compression
Symmetric cipher algorithm used is the one specified through Cypher
Examples
This sample shows how to sign and encrypt a file in one pass, backward compatibile with PGP 6.5 and below.
CopyC#
CopyVB.NET
using System; using DidiSoft.Pgp; public class SignAndEncryptV3 { public void Demo() { // Create an instance of the library PGPLib pgp = new PGPLib(); // Should output be ASCII (true) or binary (false) bool armor = false; // If true additional integrity check information will be appended bool withIntegrityCheck = false; pgp.SignAndEncryptFileV3(@"DataFiles\INPUT.txt", @"DataFiles\private.key", "password", @"DataFiles\public.key", @"DataFiles\OUTPUTse.pgp", armor); } }
VB.NET <hr></hr> Imports System Imports DidiSoft.Pgp Public Class SignAndEncryptV3 Public Sub Demo() ' Create an instance of the library Dim pgp As New PGPLib() ' Should output be ASCII (true) or binary (false) Dim asciiArmor As Boolean = False pgp.SignAndEncryptFileV3("DataFiles\INPUT.txt", _ "DataFiles\private.key", _ "password", _ "DataFiles\public.key", _ "DataFiles\OUTPUT.pgp", _ asciiArmor) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| DidiSoft.Pgp..::..PGPException | if an OpenPGP related error has occurred |
| System.IO..::..IOException | I/O error |
| DidiSoft.Pgp..::..PGPException | if an OpenPGP related error has occurred |
| System.IO..::..IOException | I/O error |
| DidiSoft.Pgp.Exceptions..::..WrongPasswordException | if the supplied password for the private key is incorrect |
| DidiSoft.Pgp.Exceptions..::..WrongPrivateKeyException | if the supplied private key is not suitable for signing |