如题

解决方案 »

  1.   

    Cookie中的数据以文本的形式存在客户端计算机,考虑它的安全性,最好在将数据存入Cookie之前对其进行加密。
    比较简单一点的加密方法有:Base64,md5,sha等
    下面是用md5加密的
    Private void Login_Click(object sender,System EventArgs e)
    {
     string Name = NameBox.Text;
     string Pass = PassBox.Text;
     Response.Cookies["name"].Value = FormsAuthentication.HashPasswordForStoringInConfigFile(Name, "md5");
            Response.Cookies["pass"].Value = FormsAuthentication.HashPasswordForStoringInConfigFile(Pass, "md5");
    }
      

  2.   

    md5、sha加密是单向的,不能用于cookie上。请参见:
    http://yefei520.cnblogs.com/archive/2006/07/14/450982.html