【发布时间】:2016-01-17 16:59:44
【问题描述】:
我对 C# 很陌生,因为我需要为我的老板做一个简单的项目。
我想收到的正是:
- 获取选定的文件以供用户解密 (OpenFileDialog)。
- 获取用户选择的文件以用作键。
- 使用函数 openssl 运行 CMD enc -d -aes-256-cbc -in userSelectedFilesToDecrypt.enc -out UserSelectedFilesAlreadyDecrypted.mp3 -pass file:./ user_selected_key_file.bin
就是这样。
我已经得到了什么:
- OpenFileDialog 供用户在两个选项(1. 和 2.)上使用
我需要什么:
- 输入/输出代码。
这是我当前的代码:
{
Process decrypt = new Process();
string processExecutable = @"C:\Windows\System32\cmd.exe";
if (!File.Exists(processExecutable))
throw new ApplicationException(string.Format("The executable file \"{0}\" does not exist.", processExecutable));
decrypt.StartInfo.FileName = processExecutable;
decrypt.StartInfo.Arguments = "/C openssl enc -d -aes-256-cbc -in FILES_IN.enc -out FILES_OUT.mp3 -pass file:./KEY_FILE.bin";
decrypt.StartInfo.UseShellExecute = false;
decrypt.StartInfo.RedirectStandardOutput = true;
decrypt.StartInfo.RedirectStandardError = true;
decrypt.StartInfo.RedirectStandardInput = true;
decrypt.StartInfo.CreateNoWindow = true;
decrypt.Start();
decrypt.BeginOutputReadLine();
decrypt.BeginErrorReadLine();
decrypt.WaitForExit();
decrypt.Close();
}
我应该如何修改它,以便能够在用户选择的文件上使用它?感谢您的帮助。
【问题讨论】:
标签: c# cmd openssl openfiledialog