Asp.net Cookie 敏感性資料加密

來源:互聯網
上載者:User
我看了一下,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檔案內

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.