WALTER | Workable Algorithms for Location-aware Transmission, Encryption Response

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

Decrypts the specified encrypted text that was encrypted using a public key.

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

Syntax


[NotNullAttribute]
[MethodImplAttribute]
public string Decrypt(
	string encryptedText,
	string privateKey
)

Parameters

encryptedText
Type: String
The encrypted text.
privateKey
Type: String
The private key.

Return Value

the deciphered text

Exceptions


ExceptionCondition
ArgumentNullExceptionencryptedText
ArgumentNullExceptionprivateKey

Examples


The bellow sample shows how to encrypt and decrypt data using a pgp key pair
C#
var keyGen = new PGPKeyGenerator();

   var keyRing = keyGen.GenerateKeys(PGPKeySize.Key2048);
   var pgp = new PGPManaged();
   var smallTextFile = "ABC";
   var secure = pgp.Encrypt(smallTextFile, keyRing.PublicKey);

   var copy = pgp.Decrypt(secure, keyRing.PrivateKey);
   Assert.AreEqual(smallTextFile, copy);