C# C语言中的GNUPG解密#
我的任务是解密从各种FTP站点检索到的pgp文件。我们在服务器上安装了GNUPG。我还评估了Bouncy Castle和StarkSoft。我真的不想购买商业解密软件。因此,我正在寻找使用BouncyCastle或.NETFramework4.5本身中的某些东西来完成此解密任务的方法。如果您使用GNUPG解密了pgp文件,请共享一个到您博客文章的链接,或者提供一些关于您的方法的见解。GPG有两种常见的风格,一种需要——命令行上的passphrase fd 0告诉它从标准输入读取passphrase另一种不需要,我忘了哪个版本需要它,但它在IIRC文件中并不明确 一切都只是正确地调用子流程。这是我的一个程序中的一个剪辑,它可以做到这一点C# C语言中的GNUPG解密#,c#,encryption,gnupg,C#,Encryption,Gnupg,我的任务是解密从各种FTP站点检索到的pgp文件。我们在服务器上安装了GNUPG。我还评估了Bouncy Castle和StarkSoft。我真的不想购买商业解密软件。因此,我正在寻找使用BouncyCastle或.NETFramework4.5本身中的某些东西来完成此解密任务的方法。如果您使用GNUPG解密了pgp文件,请共享一个到您博客文章的链接,或者提供一些关于您的方法的见解。GPG有两种常见的风格,一种需要——命令行上的passphrase fd 0告诉它从标准输入读取passphras
private string GPGEncrypt(string src)
{
FileInfo fi = new FileInfo(src);
string OutputName = GetEncryptedName(src);
if (File.Exists(OutputName))
{
if (!chkOverwrite.Checked)
{
SetStatus("Output file already exists - " + OutputName);
return "";
}
}
string path = fi.DirectoryName;
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(props.PGPExecutable);
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.WorkingDirectory = Path.GetDirectoryName(props.PGPExecutable);
string args = string.Format(
" --encrypt --recipient {0} --output \"{1}\" \"{2}\""
, txtEncryptID.Text.Trim() // 1
, OutputName // 2
, src // 3
);
txtCommandLine.Text = args;
psi.Arguments = args;
System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);
// process.StandardInput.WriteLine(CommandLine);
// process.StandardInput.Flush();
// process.StandardInput.Close();
process.WaitForExit();
int rc = process.ExitCode;
process.Close();
txtCommandLine.Text = string.Format("{0} exited with return code {1},", Path.GetFileName(props.PGPExecutable), rc);
return OutputName;
}
GPG有两种常见的风格,一种需要——命令行上的密码短语fd0告诉它从标准输入中读取密码短语,另一种不需要,我忘记了哪个版本需要它,但在文档IIRC中它是模糊的 一切都只是正确地调用子流程。这是我的一个程序中的一个剪辑,它可以做到这一点
private string GPGEncrypt(string src)
{
FileInfo fi = new FileInfo(src);
string OutputName = GetEncryptedName(src);
if (File.Exists(OutputName))
{
if (!chkOverwrite.Checked)
{
SetStatus("Output file already exists - " + OutputName);
return "";
}
}
string path = fi.DirectoryName;
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(props.PGPExecutable);
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.WorkingDirectory = Path.GetDirectoryName(props.PGPExecutable);
string args = string.Format(
" --encrypt --recipient {0} --output \"{1}\" \"{2}\""
, txtEncryptID.Text.Trim() // 1
, OutputName // 2
, src // 3
);
txtCommandLine.Text = args;
psi.Arguments = args;
System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);
// process.StandardInput.WriteLine(CommandLine);
// process.StandardInput.Flush();
// process.StandardInput.Close();
process.WaitForExit();
int rc = process.ExitCode;
process.Close();
txtCommandLine.Text = string.Format("{0} exited with return code {1},", Path.GetFileName(props.PGPExecutable), rc);
return OutputName;
}
不知道为什么这个问题的分数是-1?试着把它表述为一个问题,并认为我做得很好?不知道为什么这个问题被评为-1?试着把它当作一个问题来表达,并认为我做得很好?