/*{ * * * * * * save.Height = default_time_picker.Height; * string[] splited = new string[3]; * splited = (logon_class.Properties.Settings.Default.db).Split('=', ';'); * db.Text = splited[1]; * splited = (logon_class.Properties.Settings.Default.catalog).Split('=', ';'); * catalog.Text = splited[1]; * splited = (logon_class.Properties.Settings.Default.security).Split('=', ';'); * security.SelectedItem = splited[1]; * security.Text = splited[1]; * splited = (logon_class.Properties.Settings.Default.user).Split('=', ';'); * user.Text = splited[1]; * splited = (logon_class.Properties.Settings.Default.password).Split('=', ';'); * password.Text = splited[1]; * default_time_picker.Text = logon_class.Properties.Settings.Default.default_time; * } */ private void save_Click_1(object sender, EventArgs e) { try { SimpleEncryption encrypt = new SimpleEncryption("password"); string sql = "Data Source=" + db.Text + ";" + "Initial Catalog=" + catalog.Text + ";" + "Persist Security Info=" + security.SelectedItem.ToString() + ";"; sql += "User ID=" + user.Text + ";" + "Password="******";"; SqlDataAdapter adapter = new SqlDataAdapter("print '1'", sql); DataSet ds = new DataSet(); adapter.Fill(ds); MessageBox.Show("Изменения сохранены"); logon_class.Properties.Settings.Default.db = encrypt.Encrypt("Data Source=" + db.Text + ";"); logon_class.Properties.Settings.Default.catalog = encrypt.Encrypt("Initial Catalog=" + catalog.Text + ";"); logon_class.Properties.Settings.Default.security = encrypt.Encrypt("Persist Security Info=" + security.Text + ";"); logon_class.Properties.Settings.Default.user = encrypt.Encrypt("User ID=" + user.Text + ";"); logon_class.Properties.Settings.Default.password = encrypt.Encrypt("Password="******";"); logon_class.Properties.Settings.Default.encrypted = "1"; logon_class.Properties.Settings.Default.Save(); Program.log_write("В настройки logon_agent внесли изменения", EventLogEntryType.Warning); this.Setup_Load(sender, e); } catch (Exception ex) { Program.log_write("В программе logon_agent произошла ошибка при внесении изменений в настройки \n" + ex.ToString() + "", EventLogEntryType.Error); MessageBox.Show("Не удается подключиться к базе данных, проверьте параметры"); } }
private void save_Click(object sender, EventArgs e) { try { SimpleEncryption encrypt = new SimpleEncryption("password"); string sql = "Data Source=" + db.Text + ";" + "Initial Catalog=" + catalog.Text + ";" + "Persist Security Info=" + security.SelectedItem.ToString() + ";"; sql += "User ID=" + user.Text + ";" + "Password="******";"; SqlDataAdapter adapter = new SqlDataAdapter("print '1'", sql); DataSet ds = new DataSet(); adapter.Fill(ds); logon_class.Properties.Settings.Default.db = encrypt.Encrypt("Data Source=" + db.Text + ";"); logon_class.Properties.Settings.Default.catalog = encrypt.Encrypt("Initial Catalog=" + catalog.Text + ";"); logon_class.Properties.Settings.Default.security = encrypt.Encrypt("Persist Security Info=" + security.Text + ";"); string userstr = "User ID=" + user.Text + ";"; logon_class.Properties.Settings.Default.user = encrypt.Encrypt(userstr); logon_class.Properties.Settings.Default.password = encrypt.Encrypt("Password="******";"); if (date.SelectedItem.ToString().Equals("Месяц")) { logon_class.Properties.Settings.Default.default_time = encrypt.Encrypt("month"); } else if (date.SelectedItem.ToString().Equals("Неделю")) { logon_class.Properties.Settings.Default.default_time = encrypt.Encrypt("week"); } else if (date.SelectedItem.ToString().Equals("День")) { logon_class.Properties.Settings.Default.default_time = encrypt.Encrypt("day"); } logon_class.Properties.Settings.Default.encrypted = "1"; /* * logon_class.Properties.Settings.Default.db = ("Data Source=" + db.Text + ";"); * logon_class.Properties.Settings.Default.catalog = ("Initial Catalog=" + catalog.Text + ";"); * logon_class.Properties.Settings.Default.security = ("Persist Security Info=" + security.Text + ";"); * string userstr = "User ID=" + user.Text + ";"; * logon_class.Properties.Settings.Default.user = (userstr); * logon_class.Properties.Settings.Default.password = ("Password="******";"); * if (date.SelectedItem.ToString().Equals("Месяц")) * logon_class.Properties.Settings.Default.default_time = ("month"); * else if (date.SelectedItem.ToString().Equals("Неделю")) * logon_class.Properties.Settings.Default.default_time = ("week"); * else if (date.SelectedItem.ToString().Equals("День")) * logon_class.Properties.Settings.Default.default_time = ("day"); * logon_class.Properties.Settings.Default.encrypted = "1";*/ logon_class.Properties.Settings.Default.Save(); sql = "exec set_idle_time_for_app @idle_time='" + default_time_picker.Text + "', @workStartTime='" + workStartTime.Text + "', @workEndTime='" + workEndTime.Text + "';"; logon_class.get_settings.sql_execute(sql); MessageBox.Show("Изменения сохранены"); this.SettingsForm_Load(sender, e); } catch (Exception ex) { MessageBox.Show("Не удается подключиться к базе данных, проверьте параметры\n" + ex.ToString()); } }
public void EncryptExampleTests() { Assert.AreEqual("This is a test!", SimpleEncryption.Encrypt("This is a test!", 0)); Assert.AreEqual("hsi etTi sats!", SimpleEncryption.Encrypt("This is a test!", 1)); Assert.AreEqual("s eT ashi tist!", SimpleEncryption.Encrypt("This is a test!", 2)); Assert.AreEqual(" Tah itse sits!", SimpleEncryption.Encrypt("This is a test!", 3)); Assert.AreEqual("This is a test!", SimpleEncryption.Encrypt("This is a test!", 4)); Assert.AreEqual("This is a test!", SimpleEncryption.Encrypt("This is a test!", -1)); Assert.AreEqual("hskt svr neetn!Ti aai eyitrsig", SimpleEncryption.Encrypt("This kata is very interesting!", 1)); }
public void Update(Credential c, string id) { if (!string.IsNullOrEmpty(id)) { Dictionary <string, object> data = new Dictionary <string, object>(); string code = (c.Username + c.Description).RemoveNonAlphaNumeric().ToLower(); data.Add("Description", SimpleEncryption.Encrypt(c.Description)); data.Add("Username", SimpleEncryption.Encrypt(c.Username)); data.Add("PassKey", SimpleEncryption.Encrypt(c.PassKey)); data.Add("Code", code); sqlite.Update(defaultTable, data, "ID", id); } }
private void SetPassword(string password) { using (PasswordForm pwd = new PasswordForm(password)) { if (pwd.ShowDialog().Equals(DialogResult.OK)) { Cursor.Current = Cursors.WaitCursor; _cfgs.Set <string>("MasterPassword", SimpleEncryption.Encrypt(pwd.Password)); _password = _cfgs.Get <string>("MasterPassword"); _password = SimpleEncryption.Decrypt(_password); Cursor.Current = Cursors.Default; } else { chkSetPassword.Checked = false; } } }
public void Add(Credential c) { Dictionary <string, object> data = new Dictionary <string, object>(); string code = (c.Username + c.Description).RemoveNonAlphaNumeric().ToLower(); data.Add("Description", SimpleEncryption.Encrypt(c.Description)); data.Add("Username", SimpleEncryption.Encrypt(c.Username)); data.Add("PassKey", SimpleEncryption.Encrypt(c.PassKey)); data.Add("Code", code); if (sqlite.IsExist(defaultTable, "Code", code.ToStringType())) { sqlite.Update(defaultTable, data, "Code", code); } else { sqlite.Insert(defaultTable, data); } }
public void Add(BindingIP c) { Dictionary <string, object> data = new Dictionary <string, object>(); string code = (c.Path + c.Description).RemoveNonAlphaNumeric().ToLower(); data.Add("Description", SimpleEncryption.Encrypt(c.Description)); data.Add("IPAddress", SimpleEncryption.Encrypt(c.IPAddress)); data.Add("Path", SimpleEncryption.Encrypt(c.Path)); data.Add("AutoBind", c.AutoBind); data.Add("Code", code); if (sqlite.IsExist(defaultTable, "Code", code.ToStringType())) { sqlite.Update(defaultTable, data, "Code", code); } else { sqlite.Insert(defaultTable, data); } }
public void NullTests() { Assert.AreEqual(null, SimpleEncryption.Encrypt(null, 0)); Assert.AreEqual(null, SimpleEncryption.Decrypt(null, 0)); }
public void EmptyTests() { Assert.AreEqual("", SimpleEncryption.Encrypt("", 0)); Assert.AreEqual("", SimpleEncryption.Decrypt("", 0)); }
public void LongEncryptionStringTest() { var encryption = new SimpleEncryption(new string('c', 200)); Assert.AreEqual("A", encryption.Decrypt(encryption.Encrypt("A"))); }
public void ShortEncryptionStringTest() { var encryption = new SimpleEncryption("ab325-sdf21"); Assert.AreEqual("A", encryption.Decrypt(encryption.Encrypt("A"))); }
public void BlankEncryptionStringTest() { var encryption = new SimpleEncryption(""); Assert.AreEqual("A", encryption.Decrypt(encryption.Encrypt("A"))); }
public void EncryptTest() { string actual = _SimpleEncryption.Encrypt(PLAIN_TEXT); Assert.AreEqual(ENCRYPTED_TEXT, actual); }