示例#1
0
        private string sendmail(MailMessage _mailMessage)
        {
            using (SmtpClient smtpClient = new SmtpClient(ServerConfig.SmtpAdress, (int)ServerConfig.SmtpPort))
            {
                var cryptograph = new AESEncription();

                smtpClient.EnableSsl             = true;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.DeliveryMethod        = SmtpDeliveryMethod.Network;
                smtpClient.Credentials           = new NetworkCredential(ServerConfig.SmtpUsername, cryptograph.DecryptMensage(ServerConfig.SmtpPassword));
                try
                {
                    smtpClient.Send(_mailMessage);
                    return("Email Entregue com Sucesso");
                }
                catch (SmtpFailedRecipientsException ex)
                {
                    //var retmsg = "";
                    //for (int i = 0; i < ex.InnerExceptions.Length; i++)
                    //{
                    //    SmtpStatusCode status = ex.InnerExceptions[i].StatusCode;
                    //    return string.Format("Failed to deliver message to {0}", ex.InnerExceptions[i].FailedRecipient);
                    //}
                    return(ex.Message);
                }
                catch (Exception ex)
                {
                    return(string.Format("Exception caught in RetryIfBusy(): {0}", ex.Message.ToString()));
                }
            }
        }
示例#2
0
        //AES Encription/Description
        private static void AESFileEncription()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("AES ENCRIPTION ---------------------------------------");
            Console.WriteLine("Enter file lock password?");
            var password = Console.ReadLine();

            Console.WriteLine(@"Enter input file location? (Eg: C:\sample.txt)");
            var input = Console.ReadLine();

            Console.WriteLine($"AES Encripting... (File {input})");
            AESEncription.AES_Encrypt(input, password);
            Console.WriteLine("File Encripted");

            Console.WriteLine($"AES Decripting... (File {input}.aes)");
            AESEncription.AES_Decrypt(input + ".aes", password);
            Console.WriteLine("File Decripted");
        }
        public ActionResult ConfirmaTroca()
        {
            var conf = Session["trocaSMTP"] as UpdateSmtpViewModel;

            if (conf != null)
            {
                var cryptograph = new AESEncription();
                ViewBag.novoemail = conf.SmtpUsername;
                var config = _serverConfigRepo.GetAllConfig();
                config.SmtpAdress   = conf.SmtpAdress;
                config.SmtpPort     = conf.SmtpPort;
                config.SmtpUsername = conf.SmtpUsername;
                config.SmtpPassword = cryptograph.EncryptMensage(conf.SmtpPassword);
                _serverConfigRepo.Update(config);
                Session.Remove("trocaSMTP");
            }
            return(View());
        }
 public MyJsonResult ResetSMTP()
 {
     try
     {
         var config      = _serverConfigRepo.GetAllConfig();
         var cryptograph = new AESEncription();
         config.SmtpAdress   = "smtp.mail.yahoo.com";
         config.SmtpPort     = 587;
         config.SmtpUsername = "******";
         config.SmtpPassword = cryptograph.EncryptMensage("epncrejjztlleysk");
         _serverConfigRepo.Update(config);
         return(new MyJsonResult(true, JsonRequestBehavior.DenyGet));
     }
     catch
     {
         Response.TrySkipIisCustomErrors = true;
         Response.StatusCode             = 500;
         return(new MyJsonResult(false, JsonRequestBehavior.DenyGet));
     }
 }
示例#5
0
文件: Login.cs 项目: suhasrake/CSLERP
        public static string getCfg()
        {
            string        str = "";
            AESEncription enc = new AESEncription();

            try
            {
                string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                using (System.IO.StreamReader sr = new System.IO.StreamReader(path + "\\ERP.txt"))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        str = line;
                        str = enc.Decrypt256(str.Trim());
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(str);
        }