如题!!!!

解决方案 »

  1.   

    我这里有一个对文件加密的类不知道是否合题意,如果需要把mail留一下
      

  2.   

    #region 密钥加密
    /// <summary>
    /// 得到加密字符串
    /// </summary>
    /// <param name="strText">要加密字符串</param>
    /// <param name="strEncrKey">密钥</param>
    /// <returns>加密后字符串</returns>
    public string DesEncrypt(string strText, string strEncrKey)//加密函数
    {
    byte[] byKey=null;
    byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
    try
    {
    byKey = System.Text.Encoding.UTF8.GetBytes(strEncrKey.Substring(0,strEncrKey.Length));
    DESCryptoServiceProvider des = new DESCryptoServiceProvider();
    byte[] inputByteArray = Encoding.UTF8.GetBytes(strText);
    MemoryStream ms = new MemoryStream();
    CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write) ;
    cs.Write(inputByteArray, 0, inputByteArray.Length);
    cs.FlushFinalBlock();
    return Convert.ToBase64String(ms.ToArray());
    }
    catch(System.Exception error)
    {
    return "error:" +error.Message+"\r";
    }
    }
    /// <summary>
    /// 得到解密后字符串
    /// </summary>
    /// <param name="strText">解密字符串</param>
    /// <param name="sDecrKey">密钥</param>
    /// <returns>解密后字符串</returns>
    public string DesDecrypt(string strText,string sDecrKey)//解密函数
    {
    byte[] byKey = null;
    byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
    byte[] inputByteArray = new Byte[strText.Length];
    try
    {
    byKey = System.Text.Encoding.UTF8.GetBytes(sDecrKey.Substring(0,8));
    DESCryptoServiceProvider des = new DESCryptoServiceProvider();
    inputByteArray = Convert.FromBase64String(strText);
    MemoryStream ms = new MemoryStream();
    CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write); 
    cs.Write(inputByteArray, 0, inputByteArray.Length); 
    cs.FlushFinalBlock();
    System.Text.Encoding encoding = new System.Text.UTF8Encoding();
    return encoding.GetString(ms.ToArray());
    }
    catch(System.Exception error)
    {
    return "error:"+error.Message+"\r";
    } }
      #endregion
    把这个写的类里调用就 行了
      

  3.   

    命名空间
    using System.Web.Security;
    using System.Security.Cryptography;
      

  4.   

    [email protected]谢谢 yangxd_yi(杨一) (
      

  5.   

    yangxd_yi(杨一) 
    可否给给偶一个,谢谢!
    [email protected]
      

  6.   

    [email protected]
    发我一个,,谢谢!
      

  7.   

    大家好,我前几天发了个帖子,问题总是解决不了,希望大家看看交流交流...
    请大家相助..
    http://community.csdn.net/Expert/topic/4289/4289457.xml?temp=.8950312
      

  8.   

    强烈关注!   
    [email protected]
    谢谢