C # invoke GPG command for encrypting and decrypting file operations

Source: Internet
Author: User

public void GPG ()
{
string password = "1234567890";

System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo ("cmd.exe");
Psi. CreateNoWindow = true;
Psi. UseShellExecute = false;
Psi. Redirectstandardinput = true;
Psi. Redirectstandardoutput = true;
Psi. Redirectstandarderror = true;

Psi. WorkingDirectory = @ "D:\sofe\GnuPG";
System.Diagnostics.Process Process = System.Diagnostics.Process.Start (PSI);

Decrypt
String scommandline = @ "GPG--passphrase 1234567890--output C:\Users\LWP\Desktop\cc.txt--decrypt C:\Users\LWP\Desktop \CC.TXT.GPG ";

Encryption
String scommandline = @ "Gpg-r liwenping-e C:\Users\LWP\Desktop\cc.txt";

Process. Standardinput.writeline (Scommandline);

Process. Standardinput.flush ();
Process. Standardinput.close ();

Process. WaitForExit ();

string result = Process. Standardoutput.readtoend ();
String error = Process. Standarderror.readtoend ();
Process. Close ();
Process. Dispose ();
}

The GPG is installed before use.

Note my key and private key have not been uploaded, please register separately

Reference http://blog.csdn.net/puppylpg/article/details/50901779

C # invoke GPG command for encrypting and decrypting file operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.