private void loginBtn_Click(object sender, EventArgs e) { if (username != "" && password != "") { AuthObject[] auths = SQL_Manager.getAuthObjectByUsername(username); if (auths.Length > 0) { // Check if this pair of username and password are correct for (int i = 0; i < auths.Length; i++) { if (auths[i].username == username) { string encryptedPassword; if (auths[i].isMD5) { encryptedPassword = EncryptionManger.MD5(password); } else { encryptedPassword = EncryptionManger.easyEncryption(password, encryptionKey); } if (encryptedPassword == auths[i].encryptedPass) { MessageBox.Show("Congragulations! you are connected to Demo_SQL"); } else { MessageBox.Show("The username or the password are incorrect"); } } } } else { MessageBox.Show("The username or the password are incorrect"); } } else { MessageBox.Show("Please enter the required fields"); } }
private void button1_Click(object sender, EventArgs e) { if ( username != "" && name != "" && lastN != "" && password != "" && passAgain != "" && encrShift != "0" || username != "" && name != "" && lastN != "" && password != "" && passAgain != "" && useMD5 ) { // Checking if the passwords equal if (password == passAgain && encrShift.Length == passAgain.Length) { bool isInserted = SQL_Manager.insertNewUser( new UserRecord(username, name, lastN, EncryptionManger.easyEncryption(password, encrShift)) ); if (isInserted) { MessageBox.Show("User Inserted successfuly"); } else { MessageBox.Show("This username already exists please choose another"); } } else { if (password == passAgain && useMD5) { bool isInserted = SQL_Manager.insertNewUser( new UserRecord(username, name, lastN, EncryptionManger.MD5(password), useMD5) ); if (isInserted) { MessageBox.Show("User Inserted successfuly"); } else { MessageBox.Show("This username already exists please choose another"); } } else { string text = ""; if (encrShift.Length != password.Length || !useMD5) { text = "Encryption not at the same length as password"; } else { text = "The passwords not equal please type again."; } MessageBox.Show(text); } } } else { MessageBox.Show("Something missing... Please check"); } }