C# Encrypt a File using PGP Encryption

I have a very old process that uses GnuPG. The command line looks like this:

gpg --trust-model always --batch -u [value1] --passphrase [value2] --sign --recipient [value3] -o D:/Temp/testout.gpg -e D:/Temp/testout.txt

Open in new window


How do I achieve the same encryption results in C#?

I've tried using System.Diagnostics.Process but it doesn't work in my service application. I could use a standard PGP library but I'm not sure how to translate the values into usable code. Any help?
LVL 22
Russ SuterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
you can download the windows source here. (ancient code) Unfortunately PGP was purchased by Symantec
http://www.pgpi.org/cgi/download.cgi?filename=pgp651i-win-src.zip
0
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Hi,

You may find following articles which explain this in detail:
http://www.codeproject.com/Articles/457453/PGP-Encryption-with-Csharp
http://www.codeproject.com/Articles/3118/Gnu-Privacy-Guard-GPG-PGP-for-NET-v


Or you may find following API of interest:
https://gpgapi.codeplex.com/


Thanks and Regards,
0
btanExec ConsultantCommented:
The suggested codeproject as shared by expert is useful replacement (i.e. http://www.codeproject.com/Articles/457453/PGP-Encryption-with-Csharp) but note that it is using a wrapper interface (e.g. Starksoft OpenPGP component for .NET) to eventually execute the gpg installed in the machine. the keyring is unqiue to GnuPG so it is wrapper based or process  via C# to execute the cmd (i.e. http://www.codeproject.com/Articles/22055/Automated-File-Decryption-Using-GnuPG-and-C)

another wrapper is GnuPGWrapper v1.0, a wrapper class for GnuPG
http://www.codeguru.com/csharp/.net/net_security/pgp/article.php/c4699/Using-the-Gnu-Privacy-Guard-GnuPGPGP-within-ASPNET-v10.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Encryption

From novice to tech pro — start learning today.