Asp.net Cookie 敏感数据加密

我看了一下,cnblogs加密Cookies目录下的文件administrator@cnblogs[1].txt里面的内容
.DottextCookie
442BE3E6843561B00F1EEE6E26B50666B172699F7BFCE2592DF181C235DEC2CFF90F1408A59692B7D8835F800C0F66802B599998FD3010D40A8CB3C810994C17612C22A5539D6D36
cnblogs.com/
9728
2469185920
29850605
2699157280
29844570
*

我的方法是:
            //验证
            ValidRight.LoginSys tmp = new ValidRight.LoginSys(strUserName, strPassWord);

            
if (tmp.Pass.ToString() == "True")
            
{
                
string secretData = tmp.UserName + "," + tmp.ManaMK;
                DateTime dt 
= DateTime.Now;
                FormsAuthenticationTicket newTicket 
=new FormsAuthenticationTicket(1,"ticketNameWSF", dt,dt.AddMinutes(30), false, secretData);

                HttpCookie newUserCookie 
= new HttpCookie("theCookieWSF");
                newUserCookie.Value 
= FormsAuthentication.Encrypt(newTicket);
                newUserCookie.Expires.AddMinutes(
30);
                Response.Cookies.Add(newUserCookie); 

                FormsAuthentication.RedirectFromLoginPage(tmp.UserID, 
false);
            }
取值:
        HttpCookie userCookie = Request.Cookies["theCookieWSF"];
        FormsAuthenticationTicket ticket 
=FormsAuthentication.Decrypt(userCookie.Value);
        
string[] SPsecretData = ticket.UserData.Split(new char[] ',' });

        
this.labUserName.Text = "欢迎您," + SPsecretData[0];
这样的话数据就会存储在Cookies目录下的index.dat文件内
原文地址:https://www.cnblogs.com/cnaspnet/p/671694.html