private void Setup_Load(object sender, EventArgs e) { SimpleEncryption decrypt = new SimpleEncryption("password"); string[] splited = new string[3]; if (logon_class.Properties.Settings.Default.encrypted.Equals("1")) { splited = (decrypt.Decrypt(logon_class.Properties.Settings.Default.db)).Split('=', ';'); db.Text = splited[1]; splited = (decrypt.Decrypt(logon_class.Properties.Settings.Default.catalog)).Split('=', ';'); catalog.Text = splited[1]; splited = (decrypt.Decrypt(logon_class.Properties.Settings.Default.security)).Split('=', ';'); security.SelectedItem = splited[1]; security.Text = splited[1]; splited = decrypt.Decrypt(logon_class.Properties.Settings.Default.user).Split('=', ';'); user.Text = splited[1]; splited = decrypt.Decrypt((logon_class.Properties.Settings.Default.password)).Split('=', ';'); password.Text = splited[1]; } else { 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]; } }
public List <BindingIP> GetBindings(bool autoBinded = false) { DataTable dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_DESC, defaultTable, "ID")); if (autoBinded) { dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_WHERE, defaultTable, "AutoBind = 1")); } List <BindingIP> pwds = new List <BindingIP>(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { BindingIP cmd = new BindingIP() { ID = dr["ID"].ToSafeInteger(), IPAddress = SimpleEncryption.Decrypt(dr["IPAddress"].ToSafeString()), Description = SimpleEncryption.Decrypt(dr["Description"].ToSafeString()), Path = SimpleEncryption.Decrypt(dr["Path"].ToSafeString()), AutoBind = dr["AutoBind"].ToSafeInteger(), Code = dr["Code"].ToSafeString() }; pwds.Add(cmd); } } return(pwds); }
public BindingIP GetBinding(string id) { if (string.IsNullOrEmpty(id)) { return(null); } DataTable dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_WHERE, defaultTable, "ID=" + id)); BindingIP b = new BindingIP(); if (dt != null) { foreach (DataRow dr in dt.Rows) { try { b = new BindingIP() { ID = dr["ID"].ToSafeInteger(), IPAddress = SimpleEncryption.Decrypt(dr["IPAddress"].ToSafeString()), Description = SimpleEncryption.Decrypt(dr["Description"].ToSafeString()), Path = SimpleEncryption.Decrypt(dr["Path"].ToSafeString()), AutoBind = dr["AutoBind"].ToSafeInteger(), Code = dr["Code"].ToSafeString() }; } catch { /*@Ignore exception*/ } } } return(b); }
public Credential GetCredential(string id) { if (string.IsNullOrEmpty(id)) { return(null); } DataTable dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_WHERE, defaultTable, "ID=" + id)); Credential c = new Credential(); if (dt != null) { foreach (DataRow dr in dt.Rows) { try { c = new Credential() { ID = dr["ID"].ToSafeInteger(), Username = SimpleEncryption.Decrypt(dr["Username"].ToSafeString()), Description = SimpleEncryption.Decrypt(dr["Description"].ToSafeString()), PassKey = SimpleEncryption.Decrypt(dr["PassKey"].ToSafeString()), Code = dr["Code"].ToSafeString() }; } catch { /*@Ignore exception*/ } } } return(c); }
public void get_settings() { string check_time = ""; SimpleEncryption decrypt = new SimpleEncryption("password"); if (logon_class.Properties.Settings.Default.encrypted.Equals("1")) { connection = decrypt.Decrypt(logon_class.Properties.Settings.Default.db) + decrypt.Decrypt(logon_class.Properties.Settings.Default.catalog) + decrypt.Decrypt(logon_class.Properties.Settings.Default.security) + decrypt.Decrypt(logon_class.Properties.Settings.Default.user) + decrypt.Decrypt(logon_class.Properties.Settings.Default.password); check_time = decrypt.Decrypt(logon_class.Properties.Settings.Default.default_service_time); check_t = Convert.ToInt32(TimeSpan.Parse(check_time).TotalSeconds) * 1000; } else { connection = logon_class.Properties.Settings.Default.db + logon_class.Properties.Settings.Default.catalog + logon_class.Properties.Settings.Default.security + logon_class.Properties.Settings.Default.user + logon_class.Properties.Settings.Default.password; check_time = logon_class.Properties.Settings.Default.default_service_time; check_t = Convert.ToInt32(TimeSpan.Parse(check_time).TotalSeconds) * 1000; } }
public void DecryptExampleTests() { Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt("This is a test!", 0)); Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt("hsi etTi sats!", 1)); Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt("s eT ashi tist!", 2)); Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt(" Tah itse sits!", 3)); Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt("This is a test!", 4)); Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt("This is a test!", -1)); Assert.AreEqual("This kata is very interesting!", SimpleEncryption.Decrypt("hskt svr neetn!Ti aai eyitrsig", 1)); }
public void TestDecryptSingleCharStringToString() { IEncryption simpleEncryption = new SimpleEncryption(); string plainText = "a"; string encryptedText = simpleEncryption.EncryptToString(plainText); string decryptedText = simpleEncryption.Decrypt(encryptedText); //Make sure that we are able to get back the same plain text Assert.AreEqual(plainText, decryptedText); }
private void InitializeOptions() { _iconListManager = new IconListManager(imageList16, IconReader.IconSize.Small); _cfgs = new Configs(BindingFile.DatabaseFile); _autoSelectArchi = _cfgs.Get <bool>("AutoSelectArchitecture"); _setPassword = _cfgs.Get <bool>("SetPassword"); _isShowEnterCmd = _cfgs.Get <bool>("ShowEnterCmd"); _isKillProcesses = _cfgs.Get <bool>("KillProcess"); _operationalStatusOnly = _cfgs.Get <bool>("OperationalStatus"); menuToolbar.Checked = _cfgs.Get <bool>("Toolbar"); menuStatusbar.Checked = _cfgs.Get <bool>("Statusbar"); listViewBind.GridLines = menuGridlines.Checked = _cfgs.Get <bool>("Gridlines"); int pingCount = _cfgs.Get <int>("PingCount"); if (pingCount >= 4 && pingCount <= 100) { _pingCount = pingCount; } _responseDelay = _cfgs.Get <int>("ResponseDelay"); Color cmdcolor = _cfgs.Get <Color>("CommandColor"); if (cmdcolor != null) { _cmdColor = cmdcolor; } Font cmdFont = _cfgs.Get <Font>("CommandFont"); if (cmdFont != null) { _cmdFont = cmdFont; } listBoxLog.Font = _cmdFont; menuXPLook.Checked = _cfgs.Get <bool>("XPLook"); if (menuXPLook.Checked) { menuStripBind.RenderMode = ToolStripRenderMode.System; toolStripBind.RenderMode = ToolStripRenderMode.System; } else { menuStripBind.RenderMode = ToolStripRenderMode.Professional; toolStripBind.RenderMode = ToolStripRenderMode.Professional; } _password = _cfgs.Get <string>("MasterPassword"); _password = SimpleEncryption.Decrypt(_password); }
private void Setup_Load(object sender, EventArgs e) { check_service_state getstate = new check_service_state(); string cur_service_state = getstate.get_state("logon_server_service"); if (cur_service_state.Equals("Running") || cur_service_state.Equals("Starting")) { service_install_but.Text = "Удалить сервис"; service_control_but.Text = "Остановить сервис"; service_control_but.Enabled = true; } else if (cur_service_state.Equals("Not found")) { service_install_but.Text = "Установить сервис"; service_control_but.Enabled = false; } else { service_install_but.Text = "Удалить сервис"; service_control_but.Text = "Запустить сервис"; service_control_but.Enabled = true; } SimpleEncryption decrypt = new SimpleEncryption("password"); string[] splited = new string[3]; if (logon_class.Properties.Settings.Default.encrypted.Equals("1")) { splited = (decrypt.Decrypt(logon_class.Properties.Settings.Default.db)).Split('=', ';'); db.Text = splited[1]; splited = (decrypt.Decrypt(logon_class.Properties.Settings.Default.catalog)).Split('=', ';'); catalog.Text = splited[1]; splited = (decrypt.Decrypt(logon_class.Properties.Settings.Default.security)).Split('=', ';'); security.SelectedItem = splited[1]; security.Text = splited[1]; splited = decrypt.Decrypt(logon_class.Properties.Settings.Default.user).Split('=', ';'); user.Text = splited[1]; splited = decrypt.Decrypt((logon_class.Properties.Settings.Default.password)).Split('=', ';'); password.Text = splited[1]; default_time_picker.Text = decrypt.Decrypt(logon_class.Properties.Settings.Default.default_service_time); } else { 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_service_time; } }
static public String GetSqlString() { SimpleEncryption decrypt = new SimpleEncryption("password"); if (logon_class.Properties.Settings.Default.encrypted.Equals("1")) { string connection = decrypt.Decrypt(logon_class.Properties.Settings.Default.db) + decrypt.Decrypt(logon_class.Properties.Settings.Default.catalog) + decrypt.Decrypt(logon_class.Properties.Settings.Default.security) + decrypt.Decrypt(logon_class.Properties.Settings.Default.user) + decrypt.Decrypt(logon_class.Properties.Settings.Default.password); return(connection); } else { string connection = logon_class.Properties.Settings.Default.db + logon_class.Properties.Settings.Default.catalog + logon_class.Properties.Settings.Default.security + logon_class.Properties.Settings.Default.user + logon_class.Properties.Settings.Default.password; return(connection); } }
private void InitOptions() { _password = _cfgs.Get <string>("MasterPassword"); if (!string.IsNullOrEmpty(_password)) { try { _password = SimpleEncryption.Decrypt(_password); } catch { _password = string.Empty; } linkChange.Visible = (!string.IsNullOrEmpty(_password)); } int pingCount = _cfgs.Get <int>("PingCount"); if (pingCount > 0) { numericUpDownPingCount.Value = pingCount; } int delay = _cfgs.Get <int>("ResponseDelay"); if (delay >= 0) { numericUpDownDelay.Value = delay; } Color bc = _cfgs.Get <Color>("CommandColor"); if (bc != null) { btnColor.BackColor = bc; btnColor.Text = bc.Name; } Font cf = _cfgs.Get <Font>("CommandFont"); if (cf != null) { btnFont.Font = cf; btnFont.Text = cf.Name; } chkAutoSelecteArch.Checked = _cfgs.Get <bool>("AutoSelectArchitecture"); chkClearBindList.Checked = _cfgs.Get <bool>("ClearBindList"); chkSetPassword.Checked = _cfgs.Get <bool>("SetPassword"); chkOperationalStatus.Checked = _cfgs.Get <bool>("OperationalStatus"); chkEnterCmd.Checked = _cfgs.Get <bool>("ShowEnterCmd"); chkKillProcess.Checked = _cfgs.Get <bool>("KillProcess"); }
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 List <Credential> GetCredentials() { DataTable dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_DESC, defaultTable, "ID")); List <Credential> pwds = new List <Credential>(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { Credential cmd = new Credential() { ID = dr["ID"].ToSafeInteger(), Username = SimpleEncryption.Decrypt(dr["Username"].ToSafeString()), Description = SimpleEncryption.Decrypt(dr["Description"].ToSafeString()), PassKey = SimpleEncryption.Decrypt(dr["PassKey"].ToSafeString()), Code = dr["Code"].ToSafeString() }; pwds.Add(cmd); } } return(pwds); }
public void LongEncryptionStringTest() { var encryption = new SimpleEncryption(new string('c', 200)); Assert.AreEqual("A", encryption.Decrypt(encryption.Encrypt("A"))); }
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)); }
private void SettingsForm_Load(object sender, EventArgs e) { string[] idleTime = new string[3]; try { idleTime = logon_class.get_settings.get_idle_time(); idle_time = idleTime[0]; wStartTime = idleTime[1]; wEndTime = idleTime[2]; } catch (Exception ex) { MessageBox.Show("Произошла ошибка при получении времени простоя: \n" + ex.ToString()); idle_time = "00:05:00"; wStartTime = "09:00:00"; wEndTime = "18:00:00"; } SimpleEncryption decrypt = new SimpleEncryption("password"); string[] splited = new string[3]; if (logon_class.Properties.Settings.Default.encrypted.Equals("1")) { splited = (decrypt.Decrypt(logon_class.Properties.Settings.Default.db)).Split('=', ';'); db.Text = splited[1]; splited = (decrypt.Decrypt(logon_class.Properties.Settings.Default.catalog)).Split('=', ';'); catalog.Text = splited[1]; splited = (decrypt.Decrypt(logon_class.Properties.Settings.Default.security)).Split('=', ';'); security.SelectedItem = splited[1]; security.Text = splited[1]; splited = decrypt.Decrypt(logon_class.Properties.Settings.Default.user).Split('=', ';'); user.Text = splited[1]; splited = decrypt.Decrypt((logon_class.Properties.Settings.Default.password)).Split('=', ';'); password.Text = splited[1]; if (decrypt.Decrypt((logon_class.Properties.Settings.Default.default_time)).Equals("month")) { date.SelectedItem = "Месяц"; date.Text = "Месяц"; } else if (decrypt.Decrypt(logon_class.Properties.Settings.Default.default_time).Equals("week")) { date.SelectedItem = "Неделю"; date.Text = "Неделю"; } else if (decrypt.Decrypt(logon_class.Properties.Settings.Default.default_time).Equals("day")) { date.SelectedItem = "День"; date.Text = "День"; } } else { 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]; if (logon_class.Properties.Settings.Default.default_time.Equals("month")) { date.SelectedItem = "Месяц"; date.Text = "Месяц"; } else if (logon_class.Properties.Settings.Default.default_time.Equals("week")) { date.SelectedItem = "Неделю"; date.Text = "Неделю"; } else if (logon_class.Properties.Settings.Default.default_time.Equals("day")) { date.SelectedItem = "День"; date.Text = "День"; } } default_time_picker.Text = idle_time; workStartTime.Text = wStartTime; workEndTime.Text = wEndTime; }
public void BlankEncryptionStringTest() { var encryption = new SimpleEncryption(""); 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"))); }
private void Form1_Load(object sender, EventArgs e) { SimpleEncryption decrypt = new SimpleEncryption("password"); if (!checkPodrobn.Checked) { showPodrobn = false; } if (!checkBox2.Checked) { showAll = false; } this.userstats.Visible = false; if (date_changed == false) { if (logon_class.Properties.Settings.Default.encrypted.Equals("1")) { if (decrypt.Decrypt(logon_class.Properties.Settings.Default.default_time).Equals("month")) { startdate.Value = new DateTime(startdate.Value.Year, startdate.Value.Month, 1); } else if (decrypt.Decrypt(logon_class.Properties.Settings.Default.default_time).Equals("week")) { startdate.Value = DateTime.Now.Date.AddDays(-6); } else if (decrypt.Decrypt(logon_class.Properties.Settings.Default.default_time).Equals("day")) { startdate.Value = DateTime.Now.Date; } } else { if (logon_class.Properties.Settings.Default.default_time.Equals("month")) { startdate.Value = new DateTime(startdate.Value.Year, startdate.Value.Month, 1); } else if (logon_class.Properties.Settings.Default.default_time.Equals("week")) { startdate.Value = DateTime.Now.Date.AddDays(-6); } else if (logon_class.Properties.Settings.Default.default_time.Equals("day")) { startdate.Value = DateTime.Now.Date; } } } int i; k = 0; string begin = startdate.ToString(); string end = enddate.ToString(); if (is_rdp == null) { is_rdp = "0"; } //if (username == null) username = "******"; if (username == null) { username = "******"; } //заполняем список пользователей if (comboBox1.Items.Count < 1) { comboBox1.Items.Clear(); comboBox1.Items.Add("все пользователи"); i = 0; while (spisok_polzovateley().Length > i) { comboBox1.Items.Add(spisok_polzovateley()[i].ToString()); i++; } } k = 0; string sql = ""; //диапазон дат mindate = startdate.Value.ToString("yyyy-MM-dd"); maxdate = enddate.Value.ToString("yyyy-MM-dd"); //вывод всех try { DataSet ds = new DataSet(); if (checkBox2.Checked) { sql = "exec showall @mindate='" + mindate + "', @maxdate='" + maxdate + "', @is_rdp=" + is_rdp + ", @username="******""; k = 0; ds = dsfill(sql, ds); } else if (showPodrobn) { //вывод с РДП if (checkBox1.Checked) { sql = "exec showrdp @mindate='" + mindate + "', @maxdate='" + maxdate + "', @username="******""; k = 1; ds = dsfill(sql, ds); } //вывод мин else { sql = "exec showmin @mindate='" + mindate + "', @maxdate='" + maxdate + "', @username="******""; k = 1; ds = dsfill(sql, ds); } } //не подробный вывод else { //sql = ("select userdatetime from dbuserloginmin where username='******' and cast(userdatetime as date)='31.05.2016'"); sql = "ShowMinNePodrobno @is_rdp=" + is_rdp + ", @mindate='" + mindate + "', @maxdate='" + maxdate + "';"; ds = dsfill(sql, ds); k = 2; } dataGridView1.Columns.Clear(); dataGridView1.DataSource = ds; dataGridView1.DataMember = "table"; //форматирование datagridview if (k == 0) { this.dataGridView1.Columns[3].DefaultCellStyle.Format = @"hh\:mm\:ss"; RowsColor(5); } if (k == 1) { this.dataGridView1.Columns[2].DefaultCellStyle.Format = @"hh\:mm\:ss"; this.dataGridView1.Columns[3].DefaultCellStyle.Format = @"hh\:mm\:ss"; this.dataGridView1.Columns[4].Visible = false; RowsColor(4); } if (k == 2) { dataGridView1.AutoGenerateColumns = true; add_columns(); dataGridView1.Columns["times"].Visible = false; dataGridView1.Columns["surname"].Visible = false; // dataGridView1.Columns[3].Visible = false; } //информация о пользователе if (!username.Equals("'%'")) { this.userstats.Visible = true; string show = "За выбранный промежуток времени \n"; show += "Время на работе - " + sum_time(mindate, maxdate, username, is_rdp)[1] + "\n"; show += "Время за компьютером - " + sum_time(mindate, maxdate, username, is_rdp)[0] + "\n"; show += "Раз опоздал/раньше ушел - " + sum_time(mindate, maxdate, username, is_rdp)[2] + "\n"; show += "Раз недоработал - " + sum_time(mindate, maxdate, username, is_rdp)[3] + "\n"; this.userstats.Text = show; } resize_elements(); send = ds; this.graphic.Refresh(); } catch (Exception ex) { // MessageBox.Show(ex.ToString()); } }
public void DecryptTest() { string actual = _SimpleEncryption.Decrypt(ENCRYPTED_TEXT); Assert.AreEqual(PLAIN_TEXT, actual); }