Я пытаюсь написать консольное приложение, которое будет расшифровывать подпись gpg по запросу. Все идет нормально, ЗА ИСКЛЮЧЕНИЕМ той части, где он запрашивает мой пароль GPG. Как вызвать gpg --decrypt
из командной строки без диалога ввода пароля?
Вот мой код:
var startInfo = new ProcessStartInfo("gpg.exe");
startInfo.Arguments = "--decrypt"; //this is where I want to insert "--passphrase MyFakePassword"
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.WorkingDirectory = @"C:\Program Files (x86)\GNU\GnuPG";
var proc = Process.Start(startInfo);
var sCommandLine = stringData + "\n"+(char)26+"\n"; //stringData is the encrypted string
proc.StandardInput.WriteLine(sCommandLine);
proc.StandardInput.Flush();
proc.StandardInput.Close();
var result = proc.StandardOutput.ReadToEnd();
Я пытался использовать --passphrase MyFakePassword
, --passphrase-fd MyFakePassword
и даже --passphrase-fd 0
с моим паролем в первой строке ввода. Я бы не хотел помещать свой пароль в текстовый файл на машине, на которой выполняется этот код, если это вообще возможно.
Заранее благодарю за любую помощь.