OpenPGP digitaly signs a file.
Namespace: DidiSoft.PgpAssembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public void SignFile( FileInfo file, FileInfo privateKeyFile, string privateKeyPassword, FileInfo signedFile, bool asciiArmor ) |
| Visual Basic |
|---|
Public Sub SignFile ( _ file As FileInfo, _ privateKeyFile As FileInfo, _ privateKeyPassword As String, _ signedFile As FileInfo, _ asciiArmor As Boolean _ ) |
| Visual C++ |
|---|
public: void SignFile( FileInfo^ file, FileInfo^ privateKeyFile, String^ privateKeyPassword, FileInfo^ signedFile, bool asciiArmor ) |
Parameters
- file
- Type: System.IO..::..FileInfo
File to be OpenPGP signed
- privateKeyFile
- Type: System.IO..::..FileInfo
Private key file
- privateKeyPassword
- Type: System..::..String
Private key password
- signedFile
- Type: System.IO..::..FileInfo
Output OpenPGP signed file
- asciiArmor
- Type: System..::..Boolean
if true, output file is in ASCII armored format
Examples
This sample shows how to digitaly sign file using private key located in file
CopyC#
CopyVB.NET
using System; using System.IO; using DidiSoft.Pgp; public class SignDemo { public void Demo() { PGPLib pgp = new PGPLib(); bool armor = true; pgp.SignFile(new FileInfo(@"C:\Test\INPUT.txt"), new FileInfo(@"C:\Test\private.pkr"), "password", new FileInfo(@"C:\Test\OUTPUT.pgp"), armor); } }
Imports System Imports System.IO Imports DidiSoft.Pgp Public Class SignDemo Public Sub Demo() Dim pgp As New PGPLib() Dim armor As Boolean = True pgp.SignFile(New FileInfo("C:\Test\INPUT.txt"), _ New FileInfo("C:\Test\private.asc"), _ "password", _ New FileInfo("C:\Test\OUTPUT.pgp", _ armor) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| System.IO..::..IOException | if an I/O error has occurred |
| DidiSoft.Pgp..::..PGPException | if a signing error has occurred |
| 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 |