http://expert.csdn.net/Expert/topic/1866/1866394.xml?temp=.2852289

解决方案 »

  1.   

    用RSA进行数字签名,非常安全!
      

  2.   

    http://expert.csdn.net/Expert/topic/1925/1925045.xml?temp=9.141177E-02
      

  3.   

    可以用DSA和RSA,如:
    using System;
    using System.Text;
    using System.Security.Cryptography; class dsacrypto_SignData {
    public static void Main(String[] args){
    //先要将字符串转换为字节数组,这与编码有关。
    String str = "this is a test.";
    byte[] bytes = Encoding.ASCII.GetBytes(str);
    //选择签名方式,有RSA和DSA
    DSACryptoServiceProvider dsac = new DSACryptoServiceProvider();
    byte[] sign = dsac.SignData(bytes);
    //sign便是出来的签名结果。 //下面是认证了
    DSACryptoServiceProvider dsac2 = new DSACryptoServiceProvider();
    dsac2.FromXmlString(dsac.ToXmlString(false));
    bool ver = dsac2.VerifyData(bytes, sign);
    if (ver) {
    Console.WriteLine("通过");
    } else {
    Console.WriteLine("不能通过");
    }
    }
     }RSA类似,不过RSA比DSA慢得多,但比DSA安全。RSA可以选择关键字的大小,越大越安全
      

  4.   

    .NET中加密和解密的实现方法http://www.oscars.cseek.com/20030422/1664891.shtml
      

  5.   

    using System.IO;
    using System.Security.Cryptography;
    using System;
    namespace com.billdawson.crypto
    {
    class TextFileCrypt
    {
    public static void Main(string[] args)
    {
    string file = args[0];
    string tempfile = Path.GetTempFileName();
    //打开指定的文件
    FileStream fsIn = File.Open(file,FileMode.Open,
    FileAccess.Read);
    FileStream fsOut = File.Open(tempfile, FileMode.Open,
    FileAccess.Write);
    //定义对称算法对象实例和接口
    SymmetricAlgorithm symm = new RijndaelManaged();
    ICryptoTransform transform = symm.CreateEncryptor();
    CryptoStream cstream = new CryptoStream(fsOut,transform,
    CryptoStreamMode.Write); BinaryReader br = new BinaryReader(fsIn);
    // 读取源文件到cryptostream 
    cstream.Write(br.ReadBytes((int)fsIn.Length),0,(int)fsIn.Length);
    cstream.FlushFinalBlock();
    cstream.Close();
    fsIn.Close();
    fsOut.Close(); Console.WriteLine("created encrypted file {0}", tempfile);
    Console.WriteLine("will now decrypt and show contents"); // 反向操作--解密刚才加密的临时文件
    fsIn = File.Open(tempfile,FileMode.Open,FileAccess.Read);
    transform = symm.CreateDecryptor();
    cstream = new CryptoStream(fsIn,transform,
    CryptoStreamMode.Read); StreamReader sr = new StreamReader(cstream);
    Console.WriteLine("decrypted file text: " + sr.ReadToEnd());
    fsIn.Close();
    }
    }
    }