OpenPGP digitaly signs a string message.
Namespace: DidiSoft.PgpAssembly: 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#
CopyVB.NET
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; } }
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
| Exception | Condition |
|---|---|
| System.IO..::..IOException | If an I/O error has occurred |
| DidiSoft.Pgp..::..PGPException | if a signing error has occurred |
| DidiSoft.Pgp.Exceptions..::..WrongPasswordException | if the supplied password for the private key is incorrect |
| DidiSoft.Pgp.Exceptions..::..WrongPrivateKeyException | if the supplied private key is not suitable for signing |