C#调用GPG命令进行加密解密文件操作
public void GPG()
{
string password = "1234567890";
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.WorkingDirectory = @"D:\sofe\GnuPG";
System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);
//解密
string sCommandLine = @"gpg --passphrase 1234567890 --output C:\Users\LWP\Desktop\cc.txt --decrypt C:\Users\LWP\Desktop\cc.txt.gpg";
//加密
//string sCommandLine = @"gpg -r liwenping -e C:\Users\LWP\Desktop\cc.txt";
process.StandardInput.WriteLine(sCommandLine);
process.StandardInput.Flush();
process.StandardInput.Close();
process.WaitForExit();
string result = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
process.Close();
process.Dispose();
}
//使用前先安装好GPG
//注 本人密钥和私钥尚未上传过,请另行注册
//参考 http://blog.csdn.net/puppylpg/article/details/50901779
最新文章
- JSON字符串与JSON对象的区别
- Cordova - 使用Cordova开发iOS应用实战1(配置、开发第一个应用)
- bzoj1787
- sql事务和锁
- 带你熟悉CSS浮动
- Android图片浏览器之图片删除
- Codeforces548D:Mike and Feet(单调栈)
- XHTML
- webService请求方式快速生成代码 (Postman)
- C++ 函数对象
- 【mysql】mysql主从复制
- Odoo Linux服务器一键安装脚本使用指南
- 如何实现从Java入门到服务端项目开发的进阶?
- Linux常见企业面试题
- /var/run/yum.pid 已被锁定,PID 为 2925 的另一个程序正在运行
- django rest_framework 分页出现报错
- Delphi.XE2破解方法
- 使用pycharm开发代码上传到GitLab和GitHub
- E: could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporary unavailable) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is an other process using it
- CentOS 7 隐藏任务栏和顶栏