Cypher for .net

PGPManaged..::..Sign Method (String, String)

Signs the specified plain text.

Namespace:  Walter.Cypher.PGP
Assembly:  Walter.Cypher (in Walter.Cypher.dll)

Syntax


public string Sign(
	string plainText,
	string key
)

Parameters

plainText
Type: String
The plain text.
key
Type: String
The key.

Return Value

System.String with the signature

Exceptions


ExceptionCondition
[ArgumentNullException]plainText
[ArgumentNullException]key

Examples


You can sign large text blocks using a private key, the bellow sample uses a relatively small key of 512 bytes generating a secure signature using a fast operation, you can sign using any key size supported by the keyring
C#
var keyGen = new PGPKeyGenerator();

   var keyRing512 = keyGen.GenerateKeys(PGPKeySize.Key512);
   var pgp = new PGPManaged();
   var largeText = JsonConvert.SerializeObject(keyRing512);
   var signature = pgp.Sign(largeText, keyRing512.PrivateKey);
   var actual = pgp.VerifySignature(largeText, signature, keyRing512.PrivateKey);
   Assert.IsTrue(actual);