Contact Us Forum Customers Area

DidiSoft Ltd.

Encrypt with additional password

DidiSoft OpenPGP Library for .NET can encrypt a file with both the public key of the recipient and additional password. In this case if for some reason the corresponding private key of the recipient has been lost the encrypted file can still be decrypted with the additional password.

The example below demonstrates this in practice:

C#

using System.IO;
using DidiSoft;
 
class EncryptFileWithPassword
{
  public void Demo()
  {
	String additionalDecryptionPassword = "extra password";
 
	PGPLib pgp = new PGPLib();
	bool asciiArmor = false;
	bool withIntegrityCheck = false;
	pgp.EncryptFilePBE(@"DataFiles\INPUT.txt",
			   @"DataFiles\public.key",
			   additionalDecryptionPassword,
			   @"DataFiles\OUTPUT.pgp",
			   asciiArmor,
			   withIntegrityCheck);
  }
}

VB.NET

Imports System
Imports DidiSoft
 
Class EncryptFileWithPassword
  Public Sub Demo()
	Dim additionalDecryptionPassword As String = "extra password"
 
	Dim pgp As New PGPLib()
	Dim asciiArmor As Boolean = False
	Dim withIntegrityCheck As Boolean = False
	pgp.EncryptFilePBE("DataFiles\INPUT.txt", _
			   "DataFiles\public.key", _
			   additionalDecryptionPassword, _
			   "DataFiles\OUTPUT.pgp", _
			   asciiArmor, _
			   withIntegrityCheck)
  End Sub
End Class

<< Back to Examples