OpenPGP digitaly signs a file using OpenPGP version 3 signatures format (compatible with PGP 6.5 systems).
Namespace: DidiSoft.PgpAssembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public void SignFileV3( FileInfo file, FileInfo privateKeyFile, string privateKeyPassword, FileInfo signedFile, bool asciiArmor ) |
| Visual Basic |
|---|
Public Sub SignFileV3 ( _ file As FileInfo, _ privateKeyFile As FileInfo, _ privateKeyPassword As String, _ signedFile As FileInfo, _ asciiArmor As Boolean _ ) |
| Visual C++ |
|---|
public: void SignFileV3( 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 SignV3Demo { public void Demo() { // Create an instance of the library PGPLib pgp = new PGPLib(); // Should output be in ASCII armored format bool asciiArmor = true; pgp.SignFileV3(new FileInfo(@"C:\Test\INPUT.txt"), new FileInfo(@"C:\Test\private.pkr"), "password", new FileInfo(@"C:\Test\OUTPUT.pgp"), asciiArmor); } }
Imports System Imports System.IO Imports DidiSoft.Pgp Public Class SignV3Demo Public Sub Demo() ' Create an instance of the library Dim pgp As New PGPLib() ' Should output be in ASCII armored format Dim asciiArmor As Boolean = True pgp.SignFileV3(New FileInfo("C:\Test\INPUT.txt"), _ New FileInfo("C:\Test\private.asc"), _ "password", _ New FileInfo("C:\Test\OUTPUT.pgp", _ asciiArmor) 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 |