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