1

使用该方法创建了一个 Cookie,其实际存储的值为:

87B0B98C-3108-4367-B8EF-5A7D35F65E1D

但 cookie 中显示的实际值为:

34D20FCCC8F39594FAEA6B924535EA19834AEBE9F91D859D530735C06EDBFF5DD22CC0DCDD99FB164B8079CE00D420DEB18B209E2894D2F53A39F8352A1E3661A887259047E29E9D67755336E09B32D60C0226219EFDD0D5EE8DE48356AF6502A8752E6EA2FB3C737474F4A471EC9C181858A4D83748C9F55B4F20F6946F1F9B6F8B9E4E73717BF87F0C04F828A9C543BFA87C88CC5095C5F31570377C55EB88CF0E3E42

我的问题是,如何将 cookie 中的值转换为实际值(如果您试图在没有 .net 的情况下访问它)

或者这是你真的无法绕过的一层加密?

4

1 回答 1

1

I think that is what you looking for.

string userData = "ApplicationSpecific data for this user.";
  FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
    username,
    DateTime.Now,
    DateTime.Now.AddMinutes(30),
    isPersistent,
    userData,
    FormsAuthentication.FormsCookiePath);

  // Encrypt the ticket.
  string encTicket = FormsAuthentication.Encrypt(ticket);

  // Create the cookie.
  Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.aspx

encTicket contains the value you need.

于 2013-02-13T19:40:37.613 回答