Decrypts and verifies a PGP password based encrypted (PBE) and signed file

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

Syntax

C#
public bool DecryptAndVerifyFilePBE(
	string encryptedFileName,
	string decryptionPassword,
	string publicKeyFile,
	string outputFileName
)
Visual Basic
Public Function DecryptAndVerifyFilePBE ( _
	encryptedFileName As String, _
	decryptionPassword As String, _
	publicKeyFile As String, _
	outputFileName As String _
) As Boolean
Visual C++
public:
bool DecryptAndVerifyFilePBE(
	String^ encryptedFileName, 
	String^ decryptionPassword, 
	String^ publicKeyFile, 
	String^ outputFileName
)

Parameters

encryptedFileName
Type: System..::..String
File name to be decrypted (absolute or relative path)
decryptionPassword
Type: System..::..String
Password used to encrypt the file
publicKeyFile
Type: System..::..String
Public key file name used for signature verification (absolute or relative path)
outputFileName
Type: System..::..String
File name of the Output decrypted file (absolute or relative path)

Return Value

true if signature is valid, false if signature is invalid or there is no signature at all

Remarks

Supports OpenPGP version 3 format too (used by PGP 2.x systems).

Examples

This example demonstrates how to decrypt and verify a signed and encrypted with password OpenPGP archive.
CopyC#
using System;
using DidiSoft.Pgp;

public class DecryptAndVerifyPBE
{
  public void Demo()
  {
    PGPLib pgp = new PGPLib();
    bool validSigning = pgp.DecryptAndVerifyFilePBE(@"c:\encrypted_file.pgp",
                                                 "decryption password",
                                                 @"c:\recipient_public_key.asc",
                                                 @"c:\OUTPUT.txt");

    Console.WriteLine("Signature is valid: " + validSigning);      
  }
}
CopyVB.NET
Imports System
Imports DidiSoft.Pgp

Public Class DecryptAndVerifyPBE
  Public Sub Demo()
     Dim pgp As New PGPLib()
     Dim validSigning As Boolean = pgp.DecryptAndVerifyFilePBE("c:\encrypted_file.pgp", _
                                            "decryption password", _
                                            "c:\recipient_public_key.asc", _
                                            "c:\OUTPUT.txt")

     Console.WriteLine("Signature is valid: " + validSigning)
  End Sub
End Class

Exceptions

ExceptionCondition
DidiSoft.Pgp..::..PGPExceptionif an OpenPGP related error has occurred
System.IO..::..IOExceptionI/O error
DidiSoft.Pgp.Exceptions..::..WrongPasswordExceptionIf the decryption password is incorrect
NonPGPDataExceptionif the input data is not a valid OpenPGP encrypted message

See Also