I am trying to encrypt an incoming document in C # and I am using GnuPG with input redirection. I need to use -se (sign and encrypt) in one step, which requires a passphrase. But for some reason input redirection does not work. I appreciate your help. Control will block. I'm not sure that pending input will be deadlock or child process (gpg.exe).
pgpproc = new Process();
pgpproc.StartInfo.FileName = exeFilePath;
pgpproc.StartInfo.RedirectStandardOutput = false;
pgpproc.StartInfo.RedirectStandardInput = true;
pgpproc.StartInfo.UseShellExecute = false;
pgpproc.StartInfo.Arguments = "-a -o C:\PGPStaging\output.pgp -se -r recipientID C:\PGPStaging\input.txt";
pgpproc.StartInfo.CreateNoWindow = true;
pgpproc.Start();
StreamWriter myStreamWriter = pgpproc.StandardInput;
myStreamWriter.Write("*****");
myStreamWriter.Close();
if (pgpproc.WaitForExit(waittime))
{
}
else
{
pgpproc.Kill();
pgpproc.WaitForExit();
}
`
source
share