命令行GPG解密使用C# - 密码?命令行、密码、GPG

2023-09-04 23:02:51 作者:稍微有点酷

我使用命令行来加密我发送的文件,但我试图找出如何用同样的方法对其进行解密。如果我运行命令它得到提示输入密码,但我不明白的方式来传递中使用命令行的密码。下面是我如何加密文件:

I'm using the command line to encrypt files that I am sending out but I am trying to figure out how to use the same method to decrypt them. If I run the command it get prompted for the passphrase, but I don't see a way to pass in the passphrase using the command line. Here is how I am encrypting the file:

var proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.WorkingDirectory = "C:\\";
proc.StartInfo.FileName = @"C:\Progra~1\GNU\GnuPG\gpg.exe";
proc.StartInfo.Arguments = @"-e -u ""user1@example.com"" -r ""user2@example.com"" ""C:\file.csc""";
proc.Start();
proc.WaitForExit();

**下面是用于我的解决方案是一个有用的链接: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/38c21304-fc7a-42cc-a5fb-dcb6da7f6411/

** Here is a useful link that was used for my solution: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/38c21304-fc7a-42cc-a5fb-dcb6da7f6411/

推荐答案

属性的 Process.StandardInput 应该给你,你可以用它来提供标准输入的密码中使用StreamWriter。

The property Process.StandardInput should give you a StreamWriter that you can use to provide the passphrase on standard input.