public static long Decrypt(string userIdCookie, string controllerName) { string text = Instance <ISiteSettingService> .Create.GetSiteSettings().UserCookieKey; if (string.IsNullOrEmpty(text)) { text = SecureHelper.MD5(Guid.NewGuid().ToString()); Instance <ISiteSettingService> .Create.SaveSetting("UserCookieKey", text); } string text2 = string.Empty; try { if (!string.IsNullOrWhiteSpace(userIdCookie)) { userIdCookie = HttpUtility.UrlDecode(userIdCookie); userIdCookie = SecureHelper.DecodeBase64(userIdCookie); text2 = SecureHelper.AESDecrypt(userIdCookie, text); text2 = text2.Replace(controllerName + ",", ""); } } catch (Exception exception) { Log.Error(string.Format("解密用户标识Cookie出错,Cookie密文:{0}", userIdCookie), exception); } long result = 0L; long.TryParse(text2, out result); return(result); }
public static long Decrypt(string userIdCookie, string controllerName) { string userCookieKey = Instance <ISiteSettingService> .Create.GetSiteSettings().UserCookieKey; if (string.IsNullOrEmpty(userCookieKey)) { Guid guid = Guid.NewGuid(); userCookieKey = SecureHelper.MD5(guid.ToString()); Instance <ISiteSettingService> .Create.SaveSetting("UserCookieKey", userCookieKey); } string empty = string.Empty; try { if (!string.IsNullOrWhiteSpace(userIdCookie)) { userIdCookie = HttpUtility.UrlDecode(userIdCookie); userIdCookie = SecureHelper.DecodeBase64(userIdCookie); empty = SecureHelper.AESDecrypt(userIdCookie, userCookieKey); empty = empty.Replace(string.Concat(controllerName, ","), ""); } } catch (Exception exception) { Log.Error(string.Format("解密用户标识Cookie出错,Cookie密文:{0}", userIdCookie), exception); } long num = 0; long.TryParse(empty, out num); return(num); }
static void Main(string[] args) { /*Console.WriteLine("正在启动"); * string _categoryName = "MQ_Process"; * string _counterTPSName = "TPS"; * Console.WriteLine("创建性能计数器"); * if (PerformanceCounterCategory.Exists(_categoryName)) * { * PerformanceCounterCategory.Delete(_categoryName); * } * CounterCreationDataCollection ccdc = new CounterCreationDataCollection * { * new CounterCreationData(_counterTPSName, "TPS", PerformanceCounterType.RateOfCountsPerSecond32) * }; * * PerformanceCounterCategory.Create(_categoryName, "MQ_Process", PerformanceCounterCategoryType.MultiInstance, * ccdc); * * Console.WriteLine("创建MQ监听服务"); * PageViewProcess mp = new PageViewProcess("PVListener"); * EventProcess ep = new EventProcess("EventListener"); * Task t1 = Task.Factory.StartNew(delegate { mp.Receive(); }); * Task t2 = Task.Factory.StartNew(delegate { ep.Receive(); }); * Console.WriteLine("开始处理消息"); * Task.WaitAll(t1, t2); * Console.Read();*/ Console.WriteLine(SecureHelper.AESDecrypt(SecureHelper.DecodeBase64("dWRPVnh2bnVwYXVmYmIwSytIdEd3QT09"), "d1b31e1b3176cf3aa8993428061c8af2")); }
private static string[] ParserUser(string user) { if (String.IsNullOrWhiteSpace(user)) { return(new[] { string.Empty, "-1" }); } string u = SecureHelper.AESDecrypt(SecureHelper.DecodeBase64(user), ConfigurationManager.AppSettings["UserCookieDecryptKey"]); string[] us = u.Split(','); if (us.Length == 2) { long l; if (Int64.TryParse(us[1], out l)) { return(u.Split(',')); } return(new[] { string.Empty, "-1" }); } return(new[] { string.Empty, "-1" }); }