【发布时间】:2020-03-01 22:57:21
【问题描述】:
我们有多个带有单点登录的 Asp.Net MVC 应用程序,我们使用 FormsAuthentication.Encrypt() 方法传递加密字符串并将其作为查询字符串传递并使用 FormsAuthentication.Decrypt() 解密相同的字符串。
由于这两个站点都是在 Asp.Net MVC 中开发的,我们能够使用表单身份验证并能够解密字符串。
现在我们正在 Asp.Net Core 中开发一个新项目,我们将加密字符串作为来自 Asp.Net MVC 的查询字符串传递,并且必须在 Asp.Net Core Web 应用程序中解密。
在 Asp.Net Core 中有没有其他方法可以解密字符串
注意:我们没有使用 Asp.Net Identity
//Encryption
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, "Name", DateTime.Now, DateTime.Now.AddMinutes(60), true, "DataToEncrypt");
string encrypted = FormsAuthentication.Encrypt(ticket);
Response.Redirect("siteUrl?CookieName="+encrypted );
//Decryption
HttpCookie authCookie = Request.Cookies["CookieName"];
var formsAuthenticationTicket = FormsAuthentication.Decrypt(authCookie.Value);
string _userData = formsAuthenticationTicket.UserData;
【问题讨论】:
标签: c# asp.net asp.net-mvc asp.net-core encryption