zoukankan      html  css  js  c++  java
  • 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:sofeGnuPG";
    System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);

    //解密
    string sCommandLine = @"gpg --passphrase 1234567890 --output C:UsersLWPDesktopcc.txt --decrypt C:UsersLWPDesktopcc.txt.gpg";

    //加密
    //string sCommandLine = @"gpg -r liwenping -e C:UsersLWPDesktopcc.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

  • 相关阅读:
    react学习笔记4
    php学习笔记
    react学习笔记2
    react学习笔记
    获取一个数组中的随机值
    添加数据库补丁
    $.post $.getScript
    SQLServer2008将表数据导出的方法
    DataTable筛选符合条件的DataRow
    c# 下拉多选的实现
  • 原文地址:https://www.cnblogs.com/liwp/p/7217306.html
Copyright © 2011-2022 走看看