OpenPGP clear signs a String message, using OpenPGP version 3 signature format (old format)
GPG equivalent command: gpg --clearsign --force-v3-sigs
Namespace: DidiSoft.PgpGPG equivalent command: gpg --clearsign --force-v3-sigs
Assembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public string ClearSignStringV3( string stringToSign, string privateKeyFileName, string privateKeyPassword, HashAlgorithm hashingAlgorithm ) |
| Visual Basic |
|---|
Public Function ClearSignStringV3 ( _ stringToSign As String, _ privateKeyFileName As String, _ privateKeyPassword As String, _ hashingAlgorithm As HashAlgorithm _ ) As String |
| Visual C++ |
|---|
public: String^ ClearSignStringV3( 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 in version 3 format
Examples
This sample shows how to produce a clear signed message in OpenPGP version 3 format (old format).
CopyC#
CopyVB.NET
using DidiSoft.Pgp; using System; public class Demo { public void ClearSignStringV3Example() { string PrivateKey = "c:\private_key.asc"; string Password = "pass123"; // create an instance of the library PGPLib pgp = new PGPLib(); string inputString = "the quick brown fox jumps"; string pgpString = pgp.ClearSignStringV3(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(pgpString, publicKey, out outputString); } }
Imports DidiSoft.Pgp Imports System Imports System.IO Public Class Demo Public Sub ClearSignStringV3Example() Dim PrivateKey As String = "c:\private_key.asc" Dim Password As String = "pass123" ' create an instance of the library Dim pgp As New PGPLib() Dim inputString As String = "the quick brown fox jumps" Dim pgpString As String = pgp.ClearSignStringV3(inputString, PrivateKey, Password, HashAlgorithm.SHA1) Dim outputString As String Dim verified As Boolean = pgp.VerifyString(pgpString, PublicKey, outputString) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| System.IO..::..IOException | If an I/O error occures |
| DidiSoft.Pgp.Exceptions..::..WrongPrivateKeyException | If the supplied private key is not suitable for signing |
| DidiSoft.Pgp.Exceptions..::..WrongPasswordException | If the supplied private key password is incorrect |