Hi,
I'd like to write an application which would encrypt a file using GnuPG.
It would be a Windows Application which would run a GnuPG as a Console Application.
I found this code but it doesn't work properly.
http://www.codeproject .com/KB/security/gnupgdotnet.asp x
On the basis of this application I wrote a simple console application with some adjustments.
These are my Buildoptions:
string sBuildOptions = @" --output KALIN01_1582020 _0012_08.sig --sign --encrypt --recipient KEY_ATVP_001 KALIN01_1582020 _0012_08.xml";
The code actually starts the GPG.EXE but it stops at the PassPhrase. Even I try to enter the passphrase from the application it simply does nothing.
As you can see I tried with pInfo.CreateNoW indow = false; //true; Having no success.
I really have no idea how to write some text by the application using StandardInput and not manually.
Thanks for any hint.
I'd like to write an application which would encrypt a file using GnuPG.
It would be a Windows Application which would run a GnuPG as a Console Application.
I found this code but it doesn't work properly.
http://www.codeproject .com/KB/security/gnupgdotnet.asp x
On the basis of this application I wrote a simple console application with some adjustments.
Code:
public void ExecuteCommand() {
StreamWriter sw;
StreamReader sr;
string gpgOptions = BuildOptions();
string gpgExecutable = _bindirectory + "\\gpg.exe";
// Create startinfo object
ProcessStartInfo pInfo = new ProcessStartInfo(gpgExecutable, gpgOptions);
pInfo.WorkingDirectory = _bindirectory;
pInfo.CreateNoWindow = false; //true;
pInfo.RedirectStandardInput = true;
pInfo.RedirectStandardOutput = true;
pInfo.UseShellExecute = false;
_processObject = Process.Start(pInfo);
Thread.Sleep(500);
sw = _processObject.StandardInput;
sr = _processObject.StandardOutput;
sw.Write(_passphrase + Environment.NewLine);
sw.Flush();
sw.Write("y" + Environment.NewLine);
sw.Flush();
_processObject.Close();
string sBuildOptions = @" --output KALIN01_1582020 _0012_08.sig --sign --encrypt --recipient KEY_ATVP_001 KALIN01_1582020 _0012_08.xml";
The code actually starts the GPG.EXE but it stops at the PassPhrase. Even I try to enter the passphrase from the application it simply does nothing.
As you can see I tried with pInfo.CreateNoW indow = false; //true; Having no success.
I really have no idea how to write some text by the application using StandardInput and not manually.
Thanks for any hint.