OpenPGP clear signs a file, using OpenPGP version 3 signature format (old format)

Namespace: DidiSoft.Pgp
Assembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547

Syntax

C#
public void ClearSignFileV3(
	FileInfo inputFile,
	FileInfo privateKeyFile,
	string privateKeyPassword,
	HashAlgorithm hashingAlgorithm,
	FileInfo outputFile
)
Visual Basic
Public Sub ClearSignFileV3 ( _
	inputFile As FileInfo, _
	privateKeyFile As FileInfo, _
	privateKeyPassword As String, _
	hashingAlgorithm As HashAlgorithm, _
	outputFile As FileInfo _
)
Visual C++
public:
void ClearSignFileV3(
	FileInfo^ inputFile, 
	FileInfo^ privateKeyFile, 
	String^ privateKeyPassword, 
	HashAlgorithm hashingAlgorithm, 
	FileInfo^ outputFile
)

Parameters

inputFile
Type: System.IO..::..FileInfo
File to be clear signed
privateKeyFile
Type: System.IO..::..FileInfo
Private Key file
privateKeyPassword
Type: System..::..String
Private key password
hashingAlgorithm
Type: DidiSoft.Pgp..::..HashAlgorithm
Hashing algorithms to be used
outputFile
Type: System.IO..::..FileInfo
Output file

Remarks

Clearsigned messages contain both the original message in clear text and the signature used to verify that the message comes from a trusted sender and has not been changed.

Use when needed compatibility with PGP 2.6 and older systems.

GPG equivalent command: gpg --force-v3-sigs --clearsign inputFileName --output outputFileName

Examples

This example demonstrates how to OpenPGP clear sign a text file with the old OpenPGP signature format.
CopyC#
using System;
using System.IO;
using DidiSoft.Pgp;

class ClearSignFileV3Example 
{
 public static void Demo()
 {
    // create an instance of the library
    PGPLib pgp = new PGPLib();

    // clear text sign
    pgp.ClearSignFileV3(new FileInfo(@"DataFiles\INPUT.txt"), 
                      new FileInfo(@"DataFiles\private.key"), 
                        "private key password", 
                        HashAlgorithm.SHA256, 
                        new FileInfo(@"DataFiles\OUTPUT.sig.txt"));
 }
}
CopyVB.NET
Imports System
Imports System.IO
Imports DidiSoft.Pgp

Class ClearSignFileV3Example
 Public Shared Sub Demo()
    Dim pgp As New PGPLib()

    pgp.ClearSignFileV3(New FileInfo("DataFiles\INPUT.txt"), _
                    New FileInfo("DataFiles\private.key"), _
                    "private key password", _
                    HashAlgorithm.SHA256, _
                    New FileInfo("DataFiles\OUTPUT.sig.txt"))
 End Sub
End Class

Exceptions

ExceptionCondition
System.IO..::..IOExceptionIf an I/O error occures
DidiSoft.Pgp.Exceptions..::..WrongPrivateKeyExceptionIf the supplied private key is not suitable for signing
DidiSoft.Pgp.Exceptions..::..WrongPasswordExceptionIf the supplied private key password is incorrect

See Also