Getting Started with OpenPGP Library for .NET

This chapter is a quick introduction to the programming concepts of DidiSoft OpenPGP Library for .NET.

Before you begin

The library provides two development scenarios:

  • The first option is to store your public and private OpenPGP keys in files on the disk. This is the fast and simple way of development.
  • The second choice is to keep your keys in a KeyStore object. It is more appropriate if you will be working with a lot of recipients’ public keys and/or if you are familiar with addressing the keys by User Id or hexadecimal Key Id.

Each function of the library that operates with OpenPGP archives has overloaded versions that support the above two options.

Main classes

Below is a diagram that shows the main classes contained in the library:

Displays the main classes in DidiSoft OpenPGP Library for .NET

The main namespace is DidiSoft.Pgp and it contains the most widely used classes:
PGPLib provides PGP cryptographic functions.
RevocationLib provides key revocation functionality.
KeyStore provides container storage of OpenPGP keys.


The basic exception thrown in case of an OpenPGP error is DidiSoft.Pgp.PGPException. In most cases, you have to implement a catch clause that handles it.

The namespace  DidiSoft.Pgp.Exceptions contain subclasses that represent a specific situation, for example, WrongPasswordException indicates that the supplied password for a private key is incorrect. Please check the documentation for each function in order to see which subclasses of DidiSoft.Pgp.PGPException are thrown.

You can also take a look at our proposed exception handling strategy.

Demo projects

The library installation folder contains a subfolder named \Examples that contains a few sample applications that illustrate part of the library API in practice.

PGPLibExampleCS (C#) and PGPLibExampleVB (VB.NET) are command line projects and demonstrate both working with keys in files and with keys in a KeyStore.

KeyToolCS and KeyToolVB are WinForms applications that demonstrate operations with the KeyStore class.

FileToolCS and FileToolVB are WinForms applications that show how to perform OpenPGP encryption, decryption and signing with keys located in files.

What’s next

This chapter described in a few words the main classes provided by DidiSoft OpenPGP Library for .NET.

If you have already installed the library you can continue with the online examples.