我正在加密密码,并使用FormsAuthenticationTicket将其存储到会话值,当我检索到密码时,我无法解密密码。
如下加密
string pw="xyz";
FormsAuthenticationTicket ticketpw = new FormsAuthenticationTicket(pw, true, 1000);
string securepw = FormsAuthentication.Encrypt(ticketpw);
Session["password"] = securepw;
Run Code Online (Sandbox Code Playgroud)
我试图像下面尝试解密
1
FormsAuthenticationTicket ticketuname = new FormsAuthenticationTicket(pw, true, 1000);
string secureuname = FormsAuthentication.Decrypt(pw);
Session["password"] = securepw;
Run Code Online (Sandbox Code Playgroud)
试试2
string securepw=FormsAuthentication.Decrypt(pw);
Session["password"] = securepw;
Run Code Online (Sandbox Code Playgroud)
错误-无法将FormAuthenticationTicket转换为字符串