Decrypts a PGP encrypted file using Private key located in KeyStore.

Namespace:  DidiSoft
Assembly:  PGPLib (in PGPLib.dll) Version: 1.6.3.19546

Syntax

C#
public string DecryptFile(
	string encryptedFileName,
	KeyStore keyStore,
	string privateKeyPassword,
	string outputFileName
)
Visual Basic (Declaration)
Public Function DecryptFile ( _
	encryptedFileName As String, _
	keyStore As KeyStore, _
	privateKeyPassword As String, _
	outputFileName As String _
) As String
Visual C++
public:
String^ DecryptFile(
	String^ encryptedFileName, 
	KeyStore^ keyStore, 
	String^ privateKeyPassword, 
	String^ outputFileName
)

Parameters

encryptedFileName
Type: System..::.String
File name to be decrypted (absolute or relative path)
keyStore
Type: DidiSoft..::.KeyStore
Key store containing the Private Key
privateKeyPassword
Type: System..::.String
Private key password
outputFileName
Type: System..::.String
File name of the Output decrypted file (absolute or relative path). Optional parameter.
If empty the name stored in the PGP decrypted file is used.

Return Value

File name of the decrypted file. null if and error has occured.

Examples

CopyC#
using System;
using DidiSoft;

   public class KeyStoreDecryptFile
   {
       public static void Demo()
       {
           // initialize the KeyStore
           KeyStore keyStore = new KeyStore(@"DataFiles\key.store", "changeit");

        // initialize the library
           PGPLib pgp = new PGPLib();    

           String privateKeyPassword = "key password";
        pgp.DecryptFile(@"c:\INPUT.pgp", keyStore, privateKeyPassword, @"c:\OUTPUT.txt");            
       }
   }
CopyVB.NET
Imports System
Imports DidiSoft

   Public Class KeyStoreDecryptFile
       Public Shared Sub Demo()
           ' initialize the KeyStore
           Dim keyStore As New KeyStore("DataFiles\key.store", "changeit")

        ' initialize the library
           Dim pgp As New PGPLib()

           Dim privateKeyPassword As String = "key password"
           pgp.DecryptFile("c:\INPUT.pgp", keyStore, privateKeyPassword, "c:\OUTPUT.txt")
       End Sub
   End Class

Exceptions

ExceptionCondition
PgpExceptionif an error has occured

See Also