OpenPGP clear signs a String message, using OpenPGP version 3 signature format (old format used by PGP 2.6)
Namespace: DidiSoft.PgpAssembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public string ClearSignStringV3( string stringToSign, FileInfo privateKeyFile, string privateKeyPassword, HashAlgorithm hashingAlgorithm ) |
| Visual Basic |
|---|
Public Function ClearSignStringV3 ( _ stringToSign As String, _ privateKeyFile As FileInfo, _ privateKeyPassword As String, _ hashingAlgorithm As HashAlgorithm _ ) As String |
| Visual C++ |
|---|
public: String^ ClearSignStringV3( String^ stringToSign, FileInfo^ privateKeyFile, String^ privateKeyPassword, HashAlgorithm hashingAlgorithm ) |
Parameters
- stringToSign
- Type: System..::..String
String 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 algorithm
Return Value
OpenPGP clear text signed string
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
Use when needed compatibility with PGP 2.6 and older systems.
GPG equivalent command: gpg --force-v3-sigs --clearsign
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; using System.IO; public class Demo { public void ClearSignStringV3Example() { FileInfo PrivateKey = new FileInfo(@"c:\private_key.asc"); String Password = "pass123"; // create an instance of the library PGPLib pgp = new PGPLib(); String inputString = "stringToSign"; 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 New FileInfo("c:\private_key.asc") Dim Password As String = "pass123" ' create an instance of the library Dim pgp As New PGPLib() Dim inputString As String = "stringToSign" Dim pgpString As String = pgp.ClearSignStringV3(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
| 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 |