OpenPGP encrypts a data stream with an OpenPGP public key
Namespace: DidiSoft.PgpAssembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public void EncryptStream( Stream dataStream, string internalFileName, FileInfo publicKeyFile, Stream outputStream, bool asciiArmor ) |
| Visual Basic |
|---|
Public Sub EncryptStream ( _ dataStream As Stream, _ internalFileName As String, _ publicKeyFile As FileInfo, _ outputStream As Stream, _ asciiArmor As Boolean _ ) |
| Visual C++ |
|---|
public: void EncryptStream( Stream^ dataStream, String^ internalFileName, FileInfo^ publicKeyFile, Stream^ outputStream, bool asciiArmor ) |
Parameters
- dataStream
- Type: System.IO..::..Stream
Data to be encrypted
- internalFileName
- Type: System..::..String
string, every OpenPGP archive contains a file name associated with the encrypted data. If empty a special string '_CONSOLE' will be used.
- publicKeyFile
- Type: System.IO..::..FileInfo
Recipient public key file
- outputStream
- Type: System.IO..::..Stream
OpenPGP encrypted output
- asciiArmor
- Type: System..::..Boolean
If true the encrypted file will be in ASCII armored format, otherwise in binary format
Remarks
Compression algorithm used is the one specified through Compression
Symmetric cipher algorithm used is the one specified through Cypher
Symmetric cipher algorithm used is the one specified through Cypher
Examples
using System.IO; using DidiSoft.Pgp; class EncryptStreamDemo { public void Demo() { PGPLib pgp = new PGPLib(); Stream inputStream = File.OpenRead(@"DataFiles\INPUT.txt"); FileInfo publicKey = new FileInfo(@"DataFiles\public.asc"); Stream encryptedStream = File.OpenWrite(@"DataFiles\OUTPUT.pgp"); bool asciiArmor = true; pgp.EncryptStream(inputStream, "Input.txt", publicKey, encryptedStream, asciiArmor); } }
Imports System.IO Imports DidiSoft.Pgp Class EncryptStreamDemo Public Sub Demo() Dim pgp As New PGPLib() Dim inputStream As Stream = File.OpenRead("DataFiles\INPUT.txt") Dim publicKey As New FileInfo("DataFiles\public.asc") Dim encryptedStream As Stream = File.OpenWrite("DataFiles\OUTPUT.pgp") Dim asciiArmor As Boolean = True pgp.EncryptStream(inputStream, "Input.txt", publicKey, encryptedStream, asciiArmor) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| DidiSoft.Pgp.Exceptions..::..WrongPublicKeyException | If the supplied public key file is not usable |
| DidiSoft.Pgp..::..PGPException | if an OpenPGP related error has occurred |
| System.IO..::..IOException | I/O error |