Decrypts a PGP encrypted file using Private key file.
Namespace:
DidiSoft
Assembly:
PGPLib (in PGPLib.dll) Version: 1.6.3.19546
Syntax
| Visual Basic (Declaration) |
|---|
Public Function DecryptFile ( _
encryptedFile As FileInfo, _
privateKeyFile As FileInfo, _
privateKeyPassword As String, _
outputFile As FileInfo _
) As String |
Return Value
File name of the decrypted file. null if an error had occured.
Examples
CopyC#
public void DecryptDemo() {
PGPLib pgp = new PGPLib();
FileInfo encryptedFile = new FileInfo(@"C:\Test\INPUT.pgp");
FileInfo privateKeyFile = new FileInfo(@"C:\Test\private.key");
FileInfo outputFile = new FileInfo(@"C:\Test\decrypted.txt");
pgp.DecryptFile(encryptedFile, privateKeyFile, "pass123", outputFile);
}
CopyC#
using System;
using System.IO;
using DidiSoft;
public class DecryptDemo
{
public void Demo()
{
PGPLib pgp = new PGPLib();
FileInfo inputFile = new FileInfo(@"c:\INPUT.pgp");
FileInfo privateKeyLocation = new FileInfo(@"c:\private_key.asc");
string privateKeyPassword = "key password";
FileInfo decryptedOutput = new FileInfo(@"c:\OUTPUT.txt");
string originalFileName =
pgp.DecryptFile(inputFileLocation,
privateKeyLocation,
privateKeyPassword,
decryptedOutput);
}
}
CopyVB.NET
Imports System
Imports System.IO
Imports DidiSoft
Public Class DecryptDemo
Public Sub Demo()
Dim pgp As New PGPLib()
Dim originalFileName As String
originalFileName =
pgp.DecryptFile(New FileInfo("c:\INPUT.pgp"), _
New FileInfo("c:\private_key.asc"), _
"key password", _
New FileInfo("c:\OUTPUT.txt"))
End Sub
End Class
Exceptions
| Exception | Condition |
|---|
| PgpException | if an error has occured |
| System.IO..::.IOException | if a problem has reading input file or private key file |
See Also