private string Decryption(string key, string text, string key2 = null) { string recieve; switch (EncryptionComboBox.Text) { case "SHA 256": recieve = SHA256Crypt.Decrypt(text, key); break; case "Triple DES": recieve = TripleDESCrypt.DecryptString(key, text); break; case "3DES + SHA 256": string ShaDecryption = SHA256Crypt.Decrypt(text, key2); recieve = TripleDESCrypt.DecryptString(key, ShaDecryption); break; default: MessageBox.Show("No protocol Selected!"); recieve = null; break; } return(recieve); }
private void Sendbutton_Click(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(Send_textBox.Text)) { EncTextToSend = Send_textBox.Text; switch (EncryptionComboBox.Text) { case "SHA 256": TextToSend = SHA256Crypt.Encrypt(EncTextToSend, EncKeytextBox.Text); backgroundWorker2.RunWorkerAsync(); break; case "Triple DES": TextToSend = TripleDESCrypt.EncryptString(EncKeytextBox.Text, EncTextToSend); backgroundWorker2.RunWorkerAsync(); break; case "3DES + SHA 256": string TripleEncryption = TripleDESCrypt.EncryptString(EncKeytextBox.Text, EncTextToSend); TextToSend = SHA256Crypt.Encrypt(TripleEncryption, EncKeytextBox2.Text); backgroundWorker2.RunWorkerAsync(); break; default: MessageBox.Show("No protocol Selected!"); break; } } Send_textBox.Clear(); }
private void EncryptSHAbutton_Click(object sender, EventArgs e) { if (!(string.IsNullOrWhiteSpace(EncCiphertextBox.Text) || string.IsNullOrWhiteSpace(EncSHAKeytextBox.Text))) { EncFinalCiphertextBox.Text = DecCiphertextBox.Text = SHA256Crypt.Encrypt(EncCiphertextBox.Text, EncSHAKeytextBox.Text); } else { MessageBox.Show("No input or input is just whitespaces", "Warning!"); } }
private void enc_button_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text)) { string key = textBox1.Text; string text = textBox3.Text; textBox2.Text = SHA256Crypt.Encrypt(text, key); } else { MessageBox.Show("No input or input is just whitespaces", "Warning!"); } }
private void DecryptSHAbutton_Click(object sender, EventArgs e) { if (!(string.IsNullOrWhiteSpace(DecCiphertextBox.Text) || string.IsNullOrWhiteSpace(DecSHA_key_textBox.Text))) { string plain = SHA256Crypt.Decrypt(DecCiphertextBox.Text, DecSHA_key_textBox.Text); if (plain.Equals("CryptographicException")) { MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result = MessageBox.Show("Bad Key , Enter exact key", "Error", buttons, MessageBoxIcon.Error); } else { DecCipher2textBox.Text = plain; } } else { MessageBox.Show("No input or input is just whitespaces", "Warning!"); } }
private bool AttemptLogin(string userName, string pass) { AuthDataSet users = new AuthDataSet(); AuthDataSetTableAdapters.System_UsersTableAdapter usersAdapt = new AuthDataSetTableAdapters.System_UsersTableAdapter(); string encPass = SHA256Crypt.Encrypt(userName + "@" + pass); encPass = "******"; usersAdapt.FillByLogin(users.System_Users, userName, encPass); var table = users.System_Users; if (table.Rows.Count > 0 && table.Rows[0] != null) { var row = table.Rows[0]; User user = new User() { Id = Convert.ToInt32(row[table.IdColumn.ColumnName]), Name = row[table.NameColumn.ColumnName]?.ToString(), FullName = row[table.FullNameColumn.ColumnName]?.ToString(), Contact = new Data.ContactData() { Phone = row[table.PhoneColumn.ColumnName]?.ToString(), Phone2 = row[table.Phone2Column.ColumnName]?.ToString(), PhoneMobile = row[table.PhoneMobileColumn.ColumnName]?.ToString(), Email = row[table.EmailColumn.ColumnName]?.ToString(), } }; Properties.Settings.Default.Session = new Session() { User = user, CreatedDate = DateTime.Now }; Properties.Settings.Default.Save(); } return(Properties.Settings.Default.Session != null); }
private void dec_button_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(textBox4.Text)) { string key = textBox4.Text; string cipher = textBox2.Text; string res = SHA256Crypt.Decrypt(cipher, key); if (res.Equals("CryptographicException")) { MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result = MessageBox.Show("Bad Key , Enter exact key", "Error", buttons, MessageBoxIcon.Error); } else { textBox6.Text = res; } } else { MessageBox.Show("No input or input is just whitespaces", "Warning!"); } }