public static void loadMenuData() { menu.Clear(); Drink drink = new Drink(); var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "drinks.txt"); var arrayOfDrinksData = File.ReadAllLines(filePath); for (int i = 0; i < arrayOfDrinksData.Count(); i++) { var originalData = CryptManager.decryptText(arrayOfDrinksData[i]); var splittedData = originalData.Split('*'); List <Drink> listOfDrinks = new List <Drink>(); int count = 1; for (int j = 0; j < ((splittedData.Count() - 1) / 2); j++) { drink = new Drink(); drink.name = splittedData[count]; count++; drink.price = splittedData[count]; count++; listOfDrinks.Add(drink); } menu.Add(splittedData[0], listOfDrinks); } }
public static void loadUsersData() { users.Clear(); string[] usersDataList; var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "loginData.txt"); usersDataList = File.ReadAllLines(filePath); for (int i = 0; i < usersDataList.Count(); i++) { usersDataList[i] = CryptManager.decryptText(usersDataList[i]); } User user; for (int i = 0; i < usersDataList.Count(); i++) { user = new User(); var userData = usersDataList[i].Split('*'); user.userName = userData[0]; user.password = userData[1]; user.name = userData[2]; if (i != 0) { user.adminAccess = false; } users.Add(user); } }
private void btnTestMail_Click(object sender, EventArgs e) { CryptManager.Init(Settings); string from = Settings.MailFrom; string to = Settings.MailTo; int port = Settings.MailPort; string smtpAddress = Settings.MailSmtp; string userName = Settings.MailUserNamer; string passwort = CryptManager.Decrypt(Settings.MailCryptPasswort); MailMessage message = new MailMessage(); message.To.Add(to); message.Subject = String.Concat("Testmail - Error on SFBoty on ", Settings.Server, " with Player ", Settings.Username); message.From = new MailAddress(from); message.Body = "Dies ist eine Testmail"; SmtpClient smtp = new SmtpClient(smtpAddress, port); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.EnableSsl = true; smtp.Credentials = new NetworkCredential(userName, passwort); smtp.Timeout = 30000; try { smtp.Send(message); MessageBox.Show("Mail wurde gesendet."); } catch { MessageBox.Show("Mail wurde nicht gesendet."); } message.Dispose(); smtp.Dispose(); }
private void CreateTransform(string rgbkey, string vector) { lock (SyncRoot) { byte[] _rgbKey = Convert.FromBase64String(rgbkey); byte[] _rgbIV = Convert.FromBase64String(vector); Encryptor = CryptManager.CreateEncryptor(_rgbKey, _rgbIV); Decryptor = CryptManager.CreateDecryptor(_rgbKey, _rgbIV); } }
public static void loadProductsData() { products.Clear(); var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "product.txt"); var arrayOfProductsData = File.ReadAllLines(filePath); for (int i = 0; i < arrayOfProductsData.Count(); i++) { var originalData = CryptManager.decryptText(arrayOfProductsData[i]); products.Add(originalData); } }
private void txtPasswort_TextChanged(object sender, EventArgs e) { CryptManager.Init(Settings); if (txtPasswort.Text == "") { Settings.MailCryptPasswort = ""; } else { Settings.MailCryptPasswort = CryptManager.Encrypt(txtPasswort.Text); } }
private void txtPasswort_TextChanged(object sender, EventArgs e) { Settings.PasswordHash = txtPasswort.Text; if (!String.IsNullOrEmpty(Settings.MailCryptPasswort)) { CryptManager.Init(string.Concat(pw, server, acc)); string orgPW = CryptManager.Decrypt(Settings.MailCryptPasswort); CryptManager.Init(Settings); Settings.MailCryptPasswort = CryptManager.Encrypt(orgPW); } pw = Settings.PasswordHash; }
public static void loadOrdersData() { orders.Clear(); string[] ordersDataList; var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ordersData.txt"); ordersDataList = File.ReadAllLines(filePath); Order order; for (int i = 0; i < ordersDataList.Count(); i++) { if (i % 2 != 0) { continue; } ordersDataList[i] = CryptManager.decryptText(ordersDataList[i]); ordersDataList[i + 1] = CryptManager.decryptText(ordersDataList[i + 1]); var orderHeaderData = ordersDataList[i].Split('*'); var orderDrinks = ordersDataList[i + 1].Split('*'); order = new Order(); order.date = DateTime.Parse(orderHeaderData[0]); order.tarabyza = orderHeaderData[1]; order.price = double.Parse(orderHeaderData[2]); order.discount = double.Parse(orderHeaderData[3]); order.taxPrice = double.Parse(orderHeaderData[4]); order.servicePrice = double.Parse(orderHeaderData[5]); order.totalPrice = double.Parse(orderHeaderData[6]); Drink drink; for (int j = 0; j < orderDrinks.Count(); j++) { drink = new Drink(); drink.name = orderDrinks[j]; j++; drink.price = orderDrinks[j]; j++; drink.amount = int.Parse(orderDrinks[j]); order.drinks.Add(drink.name, drink); } if (orders.ContainsKey(order.date.ToString("dd/MM/yyyy"))) { orders[order.date.ToString("dd/MM/yyyy")].Add(order); } else { List <Order> listOfOrders = new List <Order>(); listOfOrders.Add(order); orders.Add(order.date.ToString("dd/MM/yyyy"), listOfOrders); } } }
public static void updateProductsData() { var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "product.txt"); File.WriteAllText(filePath, String.Empty); foreach (var item in products) { var cipherText = CryptManager.encryptText(item); using (StreamWriter outputFile = new StreamWriter(filePath, true)) { outputFile.WriteLine(cipherText); } } }
public void SetSettings(AccountSettings settings) { Settings = settings; CryptManager.Init(Settings); txtFrom.Text = settings.MailFrom; txtTo.Text = settings.MailTo; txtSmtp.Text = settings.MailSmtp; txtUser.Text = settings.MailUserNamer; if (!string.IsNullOrEmpty(settings.MailCryptPasswort)) { txtPasswort.Text = CryptManager.Decrypt(settings.MailCryptPasswort); } numPort.Value = settings.MailPort; ckbSendErrorMail.Checked = settings.SendErrorMail; }
protected override void BeforeUpdate(Usuario model) { var usuario = UsuarioDAO.Find(model.UsuarioId); if (usuario != null) { if (string.IsNullOrEmpty(model.Senha)) { model.Senha = usuario.Senha; } else { model.Senha = CryptManager.StringToMD5(model.Senha); } model.Token = usuario.Token; } }
protected override void BeforeSave(Usuario model, BusinessObjectAcaoEnum acao) { base.BeforeSave(model, acao); var findUsuario = Find(model.UsuarioId); if (string.IsNullOrEmpty(model.Nome)) { throw new BrokenRulesException("É necessário informar o nome do usuário"); } if (string.IsNullOrEmpty(model.Email)) { throw new BrokenRulesException("É necessário informar o email do usuário"); } if (acao == BusinessObjectAcaoEnum.IdentityInsert && string.IsNullOrEmpty(model.Senha)) { throw new BrokenRulesException("É necessário informar a senha do usuário"); } var findEmail = UsuarioDAO.ValidaEmailExistente(model.Email, model.UsuarioId); if (findEmail) { throw new BrokenRulesException("O email digitado já se está sendo utilizado!"); } if (model.Administrativo != 1) { model.Administrativo = 0; } if (!string.IsNullOrEmpty(model.Senha)) { model.Senha = CryptManager.StringToMD5(model.Senha); } else { model.Senha = findUsuario.Senha; } model.EmpresaId = EmpresaId.Value; }
private void SendErrorMail(string body) { CryptManager.Init(Account.Settings); string from = Account.Settings.MailFrom; string to = Account.Settings.MailTo; int port = Account.Settings.MailPort; string smtpAddress = Account.Settings.MailSmtp; string userName = Account.Settings.MailUserNamer; string passwort = CryptManager.Decrypt(Account.Settings.MailCryptPasswort); MailMessage message = new MailMessage(); message.To.Add(to); message.Subject = String.Concat("Error on SFBoty on ", Account.Settings.Server, " with Player ", Account.Settings.Username); message.From = new MailAddress(from); message.Body = body; SmtpClient smtp = new SmtpClient(smtpAddress, port); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.EnableSsl = true; ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; smtp.Credentials = new NetworkCredential(userName, passwort); smtp.Timeout = 30000; try { smtp.Send(message); } catch (Exception ex) { if (MessageOutput != null) { MessageOutput(this, new MessageEventsArgs("Mail konnte nicht gesendet werden.")); } if (Error != null) { Error(this, new MessageEventsArgs("Mail konnte nicht gesendet werden." + Environment.NewLine + ex.ToString())); } } message.Dispose(); smtp.Dispose(); }
public static void updateUserData() { var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "loginData.txt"); File.WriteAllText(filePath, String.Empty); for (int i = 0; i < users.Count(); i++) { string userData = ""; userData += users[i].userName + "*"; userData += users[i].password + "*"; userData += users[i].name + "*"; userData += users[i].adminAccess.ToString(); userData = CryptManager.encryptText(userData); using (StreamWriter outputFile = new StreamWriter(filePath, true)) { outputFile.WriteLine(userData); } } loadUsersData(); }
public static void saveOrder(Order order) { var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ordersData.txt"); //order.taxPrice = (order.totalPrice * order.tax); //order.servicePrice = (order.totalPrice + order.taxPrice) * order.service; string orderHeader = order.date.ToString() + "*" + order.tarabyza + "*" + order.price.ToString() + "*" + order.discount.ToString() + "*" + order.taxPrice + "*" + order.servicePrice + "*" + order.totalPrice.ToString(); string orderDrinks = ""; foreach (var drink in order.drinks.Values) { orderDrinks += drink.name + "*" + drink.price + "*" + drink.amount.ToString() + "*"; } orderDrinks = orderDrinks.Remove(orderDrinks.Length - 1, 1); orderDrinks = CryptManager.encryptText(orderDrinks); orderHeader = CryptManager.encryptText(orderHeader); using (StreamWriter outputFile = new StreamWriter(filePath, true)) { outputFile.WriteLine(orderHeader); outputFile.WriteLine(orderDrinks); } }
protected static void InitMapper() { ConfigureHandler handler = new ConfigureHandler(Configure); DomSqlMapBuilder builder = new DomSqlMapBuilder(); #if SQLMAP_ENCRYPT string encrypt_sqlmap_file = System.Configuration.ConfigurationManager.AppSettings["encrypt_sqlmap_file"]; string fileMap = HttpContext.Current.Server.MapPath(string.Format("~\\{0}", encrypt_sqlmap_file)); if (!File.Exists(fileMap)) { throw new FileNotFoundException(encrypt_sqlmap_file); } StreamReader tr = new StreamReader(fileMap, Encoding.UTF8); string input = tr.ReadToEnd(); tr.Close(); string site_key = System.Configuration.ConfigurationManager.AppSettings["site_key"] + ".key"; string output = CryptManager.DecryptString(site_key, input); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(output); _Mapper = builder.Configure(doc); #else _Mapper = builder.ConfigureAndWatch("MSSqlMap.config", handler); #endif }
public static void updateMenuData() { var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "drinks.txt"); File.WriteAllText(filePath, String.Empty); foreach (var item in menu) { string userData = item.Key + "*"; foreach (var drink in item.Value) { userData += drink.name + "*"; userData += drink.price + "*"; } userData = userData.Remove(userData.Length - 1, 1); userData = CryptManager.encryptText(userData); using (StreamWriter outputFile = new StreamWriter(filePath, true)) { outputFile.WriteLine(userData); } } }
public static bool SlowEquals(string sign1, string sign2) { return(CryptManager.SlowEquals(sign1, sign2)); }
public static bool SlowEquals(byte[] sign1, byte[] sign2) { return(CryptManager.SlowEquals(sign1, sign2)); }
public Usuario Login(string user, string pwd, int empresaId) { return(UsuarioDAO.Login(user, CryptManager.StringToMD5(pwd), empresaId)); }
public static string Encrypt(this string textToEncrypt) { return(CryptManager.Encrypt(textToEncrypt)); }
public static string Decrypt(this string textToDecrypt) { return(CryptManager.Decrypt(textToDecrypt)); }