/// <summary> /// 从cookie中拿到信息并解密 /// </summary> /// <param name="accessor"></param> /// <returns></returns> public static string GetCookie(this HttpContext httpContext, string cookieKey = CookieKey) { if (string.IsNullOrWhiteSpace(cookieKey)) { return(""); } return(DEncrypt.Decrypt(httpContext.Request.Cookies[cookieKey])); }
private static void GetConfigValue() { var mailConfig = BaseCore.Configuration.GetSection("AppSettings").GetSection("MailConfig"); foreach (var config in mailConfig.GetChildren()) { Console.WriteLine(config.Value + "——" + DEncrypt.Decrypt(config.Value)); } }
/// <summary> /// 读取配置文件后,异步发送邮件 /// </summary> /// <param name="toMail">收件地址</param> /// <param name="subj">主题</param> /// <param name="bodys">正文</param> /// <param name="enableSsl">是否启用ssl</param> /// <param name="isEncrypted">配置是否加密</param> public static async Task SendMailAsync(string toMail, string subj, string bodys, bool enableSsl = false, bool isEncrypted = true) { var mailConfig = BaseCore.Configuration.GetSection("AppSettings").GetSection("MailConfig"); var smtpServer = mailConfig["smtp"]; var userName = mailConfig["account"]; var pwd = mailConfig["pwd"]; var nickName = mailConfig["nickName"]; var fromMail = mailConfig["fromMail"]; if (isEncrypted) { smtpServer = DEncrypt.Decrypt(smtpServer); userName = DEncrypt.Decrypt(userName); pwd = DEncrypt.Decrypt(pwd); nickName = DEncrypt.Decrypt(nickName); fromMail = DEncrypt.Decrypt(fromMail); } await Task.Run(() => { SendMail(smtpServer, enableSsl, userName, pwd, nickName, fromMail, toMail, subj, bodys); }); }