OpenPGP clear signs a String message with a private key located in an KeyStore object.
GPG equivalent command: gpg --clearsign
Namespace: DidiSoft.PgpGPG equivalent command: gpg --clearsign
Assembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public string ClearSignString( string stringToSign, KeyStore keyStore, long privateKeyId, string privateKeyPassword, HashAlgorithm hashingAlgorithm ) |
| Visual Basic |
|---|
Public Function ClearSignString ( _ stringToSign As String, _ keyStore As KeyStore, _ privateKeyId As Long, _ privateKeyPassword As String, _ hashingAlgorithm As HashAlgorithm _ ) As String |
| Visual C++ |
|---|
public: String^ ClearSignString( String^ stringToSign, KeyStore^ keyStore, long long privateKeyId, String^ privateKeyPassword, HashAlgorithm hashingAlgorithm ) |
Parameters
- stringToSign
- Type: System..::..String
String to be clear signed
- keyStore
- Type: DidiSoft.Pgp..::..KeyStore
KeyStore containing the signing private key
- privateKeyId
- Type: System..::..Int64
signing private key Id
- privateKeyPassword
- Type: System..::..String
signing 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 when our siging key is in a KeyStore
CopyC#
CopyVB.NET
using System; using DidiSoft.Pgp; classKeyStoreClearSignString { public static void Demo() { // initialize the key store KeyStore ks = new KeyStore(@"DataFiles\key.store", "password"); string signingKeyId = ks.GetKeyIdForKeyIdHex("8BA4CF8F"); string signingKeyPassword = "password"; // create an instance of the library PGPLib pgp = new PGPLib(); string plainText = "Hello World"; // clear text sign string clearSignedString = pgp.ClearSignString( plainText, ks, signingKeyUserId, signingKeyPassword, HashAlgorithm.SHA1); } }
Imports System Imports DidiSoft.Pgp ClassKeyStoreClearSignString Public Shared Sub Demo() ' initialize the key store Dim ks As New KeyStore("DataFiles\key.store", "password") Dim signingKeyId As Long = ks.GetKeyIdForKeyIdHex("8BA4CF8F") Dim signingKeyPassword As String = "password" ' create an instance of the library Dim pgp As New PGPLib() Dim plainText As String = "Hello World" Dim clearSignedString As String = pgp.ClearSignString(plainText, ks, _ signingKeyId, _ signingKeyPassword, _ HashAlgorithm.SHA1) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| System.IO..::..IOException | If an I/O error occures |
| DidiSoft.Pgp.Exceptions..::..WrongPrivateKeyException | If there is no private key in this KeyStore having such Key Id |
| DidiSoft.Pgp.Exceptions..::..WrongPasswordException | If the supplied private key password is incorrect |