Verifies that the incoming string is signed from a trusted sender.
The sender public key must be already imported in theKeyStore parameter.
Namespace: DidiSoft.PgpAssembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
Parameters
- signedString
- Type: System..::..String
OpenPGP signed string message
- keyStore
- Type: DidiSoft.Pgp..::..KeyStore
KeyStore object to be searched for a public key to verify the signature
- plainText
- Type: System..::..String%
Plain text extracted message.
Must be called with the out keyword in C#. In VB.NET is a normal ByRef invokation.
Return Value
true if a suitable public key to verify the message exists in the suppliedKeyStore object,
false otherwise.
Examples
CopyC#
using System;
using DidiSoft.Pgp;
classKeyStoreVerifyString
{
public static void Demo()
{
String signedString = ...
String plainText;
PGPLib pgp = new PGPLib();
KeyStore ks = new KeyStore(@"DataFiles\key.store", "password");
bool validSignature = pgp.VerifyString(signedString,
ks,
out plainText);
Console.WriteLine("Extracted plain text message is " + plainText);
if (validSignature)
{
Console.WriteLine("Signature is valid");
}
else
{
Console.WriteLine("Signature is invalid");
}
}
}
CopyVB.NET
Imports System
Imports DidiSoft.Pgp
ClassKeyStoreVerifyString
Public Shared Sub Demo()
Dim signedString As String =KeyStoreSignString.Demo()
Dim plainText As String
Dim pgp As New PGPLib()
Dim ks As New KeyStore("DataFiles\key.store", "password")
Dim validSignature As Boolean = pgp.VerifyString(signedString, ks, plainText)
Console.WriteLine("Extracted plain text message is " + plainText)
If validSignature Then
Console.WriteLine("Signature is valid")
Else
Console.WriteLine("Signature is invalid")
End If
End Sub
End Class
Exceptions
See Also