OpenPGP clear signs a String message.

GPG equivalent command: gpg --clearsign

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

Syntax

C#
public string ClearSignString(
	string stringToSign,
	string privateKeyFileName,
	string privateKeyPassword,
	HashAlgorithm hashingAlgorithm
)
Visual Basic
Public Function ClearSignString ( _
	stringToSign As String, _
	privateKeyFileName As String, _
	privateKeyPassword As String, _
	hashingAlgorithm As HashAlgorithm _
) As String
Visual C++
public:
String^ ClearSignString(
	String^ stringToSign, 
	String^ privateKeyFileName, 
	String^ privateKeyPassword, 
	HashAlgorithm hashingAlgorithm
)

Parameters

stringToSign
Type: System..::..String
String to be clear signed
privateKeyFileName
Type: System..::..String
Private Key file (absolute or relative path)
privateKeyPassword
Type: System..::..String
Private key password
hashingAlgorithm
Type: DidiSoft.Pgp..::..HashAlgorithm
Hashing algorithm

Return Value

clear signed string message

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.

Examples

This sample shows how to produce a clear signed message.
CopyC#
using DidiSoft.Pgp;
using System;
using System.IO;

public class Demo
   {
       public void ClearSignStringTest()
    {
        string privateKey = @"c:\private_key.asc";    
        string password = "pass123";

        string inputString = "the quick brown fox jumps"; 

        // create an instance of the library
        PGPLib pgp = new PGPLib(); 
        string clearSignedString = pgp.ClearSignString(inputString, privateKey, password, HashAlgorithm.SHA1);

        // the lines below demonstrate how can be verified the signature of the message
        string publicKey = @"c:\public_key.asc";

        string outputString;
        bool verified = pgp.VerifyString(clearSignedString, publicKey, out outputString);
    }
}
CopyVB.NET
Imports DidiSoft.Pgp
Imports System
Imports System.IO

Public Class Demo
    Public Sub ClearSignStringTest()
        Dim privateKey As String = "c:\private_key.asc"
        Dim password As String = "pass123"

        Dim inputString As String = "the quick brown fox jumps"

        ' create an instance of the library
        Dim pgp As New PGPLib()
        Dim pgpString As String = pgp.ClearSignString(inputString, privateKey, password, HashAlgorithm.SHA1)

        ' the lines below demonstrate how can be verified the signature of the message
        Dim publicKey As String = "c:\public_key.asc"

        Dim outputString As String
        Dim verified As Boolean = pgp.VerifyString(pgpString, publicKey, outputString)
    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