OpenPGP digitaly signs a string message.

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

Syntax

C#
public string SignStringV3(
	string stringToSign,
	Stream privateKeyStream,
	string privateKeyPassword
)
Visual Basic
Public Function SignStringV3 ( _
	stringToSign As String, _
	privateKeyStream As Stream, _
	privateKeyPassword As String _
) As String
Visual C++
public:
String^ SignStringV3(
	String^ stringToSign, 
	Stream^ privateKeyStream, 
	String^ privateKeyPassword
)

Parameters

stringToSign
Type: System..::..String
String message to be signed
privateKeyStream
Type: System.IO..::..Stream
Private key as stream, used for signing
privateKeyPassword
Type: System..::..String
Private key password

Return Value

stringToSign OpenPGP signed

Examples

This example shows how to OpenPGP sign a string message
CopyC#
using System;
using System.IO;

using DidiSoft.Pgp;

class SignStringV3
{
    public static String Demo()
    {
        String plainString = "Hello World";

        // initialize the library 
        PGPLib pgp = new PGPLib();

        Stream privateKeyStream = File.OpenRead(@"c:\private.key");

        String signedString = pgp.SignStringV3(plainString,
                                             privateKeyStream,
                                             "private key password");
        return plainString;
    }
}
CopyVB.NET
Imports System
Imports System.IO

Imports DidiSoft.Pgp

Class SignStringV3
    Public Shared Function Demo() As String
        Dim plainString As String = "Hello World"

        ' initialize the library 
        Dim pgp As New PGPLib()

        Dim privateKeyStream As Stream = File.OpenRead("c:\private.key")

        Dim signedString As String = pgp.SignStringV3(plainString, _
                                                    privateKeyStream, _
                                                    "private key password")
        Return plainString
    End Function
End Class

Exceptions

ExceptionCondition
System.IO..::..IOExceptionIf an I/O error has occurred
DidiSoft.Pgp..::..PGPExceptionif a signing error has occurred
DidiSoft.Pgp.Exceptions..::..WrongPasswordExceptionif the supplied password for the private key is incorrect
DidiSoft.Pgp.Exceptions..::..WrongPrivateKeyExceptionif the supplied private key is not suitable for signing

See Also