コード例 #1
0
        public bool send(List <usuario> users, plantilla plantilla, evaluacione evaluacion)
        {
            string from     = System.Configuration.ConfigurationManager.AppSettings["email"];
            string password = System.Configuration.ConfigurationManager.AppSettings["password"];
            string port     = System.Configuration.ConfigurationManager.AppSettings["endpoint"];

            try
            {
                mail.Subject               = "Evaluacion ";
                mail.From                  = new MailAddress(from);
                smtp.Host                  = "smtp.gmail.com";
                smtp.Port                  = 587;
                smtp.EnableSsl             = true;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = new NetworkCredential(from, password);
                mail.IsBodyHtml            = true;

                foreach (var user in users)
                {
                    mail.To.Add(new MailAddress(user.correo));
                    mail.Body = "<h4>Buenas puedes ingresar a realizar la evaluacion de " + evaluacion.usuario.nombre + " "
                                + evaluacion.usuario.apellido + "</h4>";
                    mail.Body = "<h2>" + port + AES256.encryptPassword(evaluacion.id_evaluacion.ToString()) + "/" +
                                AES256.encryptPassword(user.id_usuario.ToString()) + " - " + evaluacion.producto.nombre + "</h2>";
                    smtp.Send(mail);
                }

                return(true);
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
                return(false);
            }
        }
コード例 #2
0
        public static string encryptPassword(string password)
        {
            string key = "ThisKeyIs1345dh";

            byte[] bytesToBeEncrypted = Encoding.UTF8.GetBytes(password);
            byte[] passwordBytes      = Encoding.UTF8.GetBytes(key);
            passwordBytes = SHA256.Create().ComputeHash(passwordBytes);
            byte[] bytesEncrypted = AES256.AES_Encrypt(bytesToBeEncrypted, passwordBytes);
            return(Convert.ToBase64String(bytesEncrypted));
        }