public void SetSessionItem <TClass>(string key, TClass value) { try { byte[] IV = CryptoService.SetUnique16BitAES_IV(); Session[key + keyCacheSeparator + Convert.ToBase64String(IV)] = CryptoService.AES_Encrypt(JsonConvert.SerializeObject(value), IV); } catch (Exception e) { LoggerService.LogException(e); } }
public void ProcessEmailVerification(string userId, string email, string alias, string route = "Account/ConfirmEmail", string message = "Para confirmar la cuenta") { string[] routeParts = route.Split('/'); var infoToEncript = string.Format("{0}{1}{2}", userId, Resources.KeyCacheSeparator, DateTime.Now.AddMinutes(CodesExpirationInterval).ToString()); AES_Result code = CryptoService.AES_Encrypt(infoToEncript); var callbackUrl = Url.Action(routeParts[1], routeParts[0], new { userId, code = string.Format("{0}{1}{2}", code.CipherData, Resources.KeyCacheSeparator, code.Nonce) }, protocol: Request.Url.Scheme); EmailService es = new EmailService(); Task.Run(() => es.SendAsync(new IdentityMessage() { Destination = string.Format("{0}{1}{2}", email, Resources.KeyCacheSeparator, alias), Subject = "Confirmar cuenta", Body = string.Format("{0}{1}{2}{3}", message, ", haga clic <a href=\"", callbackUrl, "\">aquĆ</a>") })); }