Signs and encrypts a file in one pass.
The file is encrypted with an additional password that can be used to decrypt the file afterwards.
Namespace: DidiSoft.PgpThe file is encrypted with an additional password that can be used to decrypt the file afterwards.
Assembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public void SignAndEncryptFilePBE( string inputFileName, string privateKeyFileName, string privateKeyPassword, string publicKeyFileName, string additionalDecryptionPassword, string outputFileName, bool armor, bool withIntegrityCheck ) |
| Visual Basic |
|---|
Public Sub SignAndEncryptFilePBE ( _ inputFileName As String, _ privateKeyFileName As String, _ privateKeyPassword As String, _ publicKeyFileName As String, _ additionalDecryptionPassword As String, _ outputFileName As String, _ armor As Boolean, _ withIntegrityCheck As Boolean _ ) |
| Visual C++ |
|---|
public: void SignAndEncryptFilePBE( String^ inputFileName, String^ privateKeyFileName, String^ privateKeyPassword, String^ publicKeyFileName, String^ additionalDecryptionPassword, String^ outputFileName, bool armor, bool withIntegrityCheck ) |
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)
- privateKeyPassword
- Type: System..::..String
Private key password
- publicKeyFileName
- Type: System..::..String
Public key file used for encryption (absolute or relative path)
- additionalDecryptionPassword
- Type: System..::..String
Additional password that can be used to decrypt the file afterwards
- outputFileName
- Type: System..::..String
File name of the output encrypted file (absolute or relative path)
- armor
- Type: System..::..Boolean
if true, output file is in ASCII armored format
- withIntegrityCheck
- Type: System..::..Boolean
Should integrity check information be added to the file.
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.
CopyC#
CopyVB.NET
using System; using DidiSoft.Pgp; public class SignAndEncrypt { public void Demo() { // create an instance of the library PGPLib pgp = new PGPLib(); // should output be ASCII or binary bool asciiArmor = false; // should integrity check information be added bool withIntegrityCheck = false; string additionalDecryptionPassword = "backup password"; pgp.SignAndEncryptFilePBE(@"DataFiles\INPUT.txt", @"DataFiles\private.key", "password", @"DataFiles\public.key", additionalDecryptionPassword, @"DataFiles\OUTPUTse.pgp", asciiArmor, withIntegrityCheck); } }
VB.NET <hr></hr> Imports System Imports DidiSoft.Pgp Public Class SignAndEncrypt Public Sub Demo() ' create an instance of the library Dim pgp As New PGPLib() ' should output be ASCII or binary Dim asciiArmor As Boolean = False ' should integrity check information be added Dim withIntegrityCheck As Boolean = False Dim additionalDecryptionPassword As String = "backup password" pgp.SignAndEncryptFilePBE("DataFiles\INPUT.txt", _ "DataFiles\private.key", _ "password", _ "DataFiles\public.key", _ additionalDecryptionPassword, _ "DataFiles\OUTPUT.pgp", _ asciiArmor, _ withIntegrityCheck) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| DidiSoft.Pgp..::..PGPException | if an OpenPGP related error has occurred |
| System.IO..::..IOException | I/O error |