GnuPG Wrapper with C#

2020-02-10 09:32发布

问题:

I use GnuPG and C# to encrypt files with imported public keys. But when I try to make encryption, GnuPG encrypt file with public key of main user. I'm sure that I pass right recipient.

回答1:

You can try using my open source and free GnuPG wrapper for C# (and VB.NET). All the code is licensed via MIT, non-GPL restrictions. You can find the release with source code at CodePlex. Look for the Alpha release to find the GPG library.

http://biko.codeplex.com/

Example:

  GnuPG gpg = new GnuPG();

  gpg.Recipient = "myfriend@domain.com";
  FileStream sourceFile = new FileStream(@"c:\temp\source.txt", FileMode.Open); 
  FileStream outputFile = new FileStream(@"c:\temp\output.txt", FileMode.Create);

  // encrypt the data using IO Streams - any type of input and output IO Stream can be used
  gpg.Encrypt(sourceFile, outputFile);