Signs and encrypts a file in one pass.
Namespace:
DidiSoftAssembly: PGPLib (in PGPLib.dll) Version: 1.6.3.19546
Syntax
| C# |
|---|
public void SignAndEncryptFile( string inputFileName, string privateKeyFileName, string password, string publicKeyFileName, string outputFileName, bool armor, bool withIntegrityCheck ) |
| Visual Basic (Declaration) |
|---|
Public Sub SignAndEncryptFile ( _ inputFileName As String, _ privateKeyFileName As String, _ password As String, _ publicKeyFileName As String, _ outputFileName As String, _ armor As Boolean, _ withIntegrityCheck As Boolean _ ) |
| Visual C++ |
|---|
public: void SignAndEncryptFile( String^ inputFileName, String^ privateKeyFileName, String^ password, String^ publicKeyFileName, 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)
- 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)
- 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 compressing 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; public class SignAndEncrypt { public void Demo() { PGPLib pgp = new PGPLib(); bool armor = false; bool withIntegrityCheck = false; pgp.SignAndEncryptFile(@"DataFiles\INPUT.txt", @"DataFiles\private.key", "changeit", @"DataFiles\public.key", @"DataFiles\OUTPUTse.pgp", armor, withIntegrityCheck); } }
VB.NET <hr></hr> Imports System Imports DidiSoft Public Class SignAndEncrypt Public Sub Demo() Dim pgp As New PGPLib() Dim armor As Boolean = False Dim withIntegrityCheck As Boolean = False pgp.SignAndEncryptFile("DataFiles\INPUT.txt", _ "DataFiles\private.key", _ "changeit", _ "DataFiles\public.key", _ "DataFiles\OUTPUT.pgp", _ armor, _ withIntegrityCheck) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| PgpException | if an error has occured |
| System.IO..::.IOException | if a problem has reading input file or private key file |