GithubHelp home page GithubHelp logo

chopgp's Introduction

Cinchoo PGP

PGP wrapper library for .NET

Simple, intutive PGP wrapper library for .NET. Extremely clean, flexible, and easy to use.

Install

To install Cinchoo PGP, run the following command in the Package Manager Console

.NET Framework NuGet

PM> Install-Package ChoPGP

.NET Core NuGet

PM> Install-Package ChoPGP.Core

Add namespace to the program

using Cinchoo.PGP;

How to use

1. To PGP encrypt a file

public void EncryptFile(string inputFilePath, string outputFilePath, 
           string publicKeyFilePath, bool armor, bool withIntegrityCheck);
           

where:

inputFilePath - Plain data file path to be encrypted
outputFilePath - Output PGP encrypted file path
publicKeyFilePath - PGP public key file path
armor - True, means a binary data representation as an ASCII-only text. Otherwise, false
withIntegrityCheck - True, to perform integrity packet check on input file. Otherwise, false

Sample

using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
{
    pgp.EncryptFile("SampleData.txt", "SampleData.PGP", "Pub.asc", true, false);
}

2. To PGP encrypt and Sign a file

public void EncryptFileAndSign(string inputFilePath, string outputFilePath, 
           string publicKeyFilePath, string privateKeyFilePath, string passPhrase, bool armor, bool withIntegrityCheck);
           

where:

inputFilePath - Plain data file path to be encrypted
outputFilePath - Output PGP encrypted file path
publicKeyFilePath - PGP public key file path
privateKeyFilePath - PGP secret key file path
passPhrase - PGP secret key password
armor - True, means a binary data representation as an ASCII-only text. Otherwise, false
withIntegrityCheck - True, to perform integrity packet check on input file. Otherwise, false

Sample

using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
{
    pgp.EncryptFileNSign("SampleData.txt", "SampleData.PGP", "Pub.asc", "Pri.asc", "Test123", true, false);
}

3. To PGP decrypt a file

public void DecryptFile(string inputFilePath, string outputFilePath, 
           string privateKeyFilePath, string passPhrase);
           

where:

inputFilePath - PGP encrypted data file
outputFilePath - Output of decrypted file path
privateKeyFilePath - PGP secret key file path
passPhrase - PGP secret key password

Sample

using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
{
    pgp.DecryptFile("SampleData.PGP", "SampleData.OUT", "Pri.asc", "Test123");
}

4. To PGP decrypt and Verify a file

public void DecryptFile(string inputFilePath, string outputFilePath, string publicKeyFilePath,
           string privateKeyFilePath, string passPhrase);
           

where:

inputFilePath - PGP encrypted data file
outputFilePath - Output of decrypted file path
publicKeyFilePath - PGP public key file path
privateKeyFilePath - PGP secret key file path
passPhrase - PGP secret key password

Sample

using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
{
    pgp.DecryptFileNVerify("SampleData.PGP", "SampleData.OUT", "Pub.asc", "Pri.asc", "Test123");
}

5. Generate Public/Private Keyring

    public void GenerateKey(Stream publicKeyStream, Stream privateKeyStream, 
           string username = null, string password = null, int strength = 1024, int certainty = 8);
           

where:

publicKeyFilePath - File path to store the PGP public key info. Put this key on your website or at the bottom signature of your email messages. Anyone wishing to contact you in private will have your public PGP to send you encrypted messages
privateKeyFilePath - File path to store the PGP private key info. Save your PGP private key in a file on your computer and keep it as confidential as possible.
userName - Your email address is recommended for generating your PGP keys. Your email address will be included as public information in your public PGP key, so your public key can be easily imported by any third-party PGP software. If you do not supply your email address, your PGP decryption software may be unable to link your email address to your public PGP key, and therefore unable to automatically encrypt/decrypt email messages. As a result, you will have to manually decrypt messages each time you receive a PGP-encrypted message.
password - Pick a password to protect your private PGP key. This password offers an extra layer of protection in case someone manages to steal your public PGP key.
strength - The key strength. Default value is 1024.
certainty - Certainty for prime evaluation. Bouncy Castle uses this number to generate random number and checks whether or not they are prime numbers using prime test algorithm. Default value is 8.

Sample

using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
    pgp.GenerateKey("pub.asc", "pri.asc", "[email protected]", "Test123");

If this project help you reduce time to develop, you can give me a cup of coffee :)

$10/$25/$50/$100

chopgp's People

Contributors

cinchoo avatar athoik avatar chriscrew avatar nickromero avatar raceprouk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.