public static string Encrypt(long userId, string controllerName) { string str; 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 { string str1 = string.Concat(controllerName, ",", userId.ToString()); empty = SecureHelper.AESEncrypt(str1, userCookieKey); empty = SecureHelper.EncodeBase64(empty); str = empty; } catch (Exception exception) { Log.Error(string.Format("加密用户标识Cookie出错", empty), exception); throw; } return(str); }
public static string Encrypt(long userId, 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; string result; try { string encryptStr = controllerName + "," + userId.ToString(); text2 = SecureHelper.AESEncrypt(encryptStr, text); text2 = SecureHelper.EncodeBase64(text2); result = text2; } catch (Exception exception) { Log.Error(string.Format("加密用户标识Cookie出错", text2), exception); throw; } return(result); }