/************************************* * Makes sure user entered a valid Id, and a valid password as well, * then updates password w/ the given one from the user. * Displays any messages as needed *************************************/ private void modifyDataButton_Click(object sender, EventArgs e) { string inID = IDModifyDataTextBox.Text; //bring in text box data string inPass = passwordModifyDataTextBox.Text; //bring in text box data if (searchForID(inID)) //ID was found { if (passwordReqCheck(inPass)) //user entered password meets reqs { for (int i = 0; i < accountList.Count; i++) //cycle thru accountList { if (accountList[i].IdNumber.Equals(inID)) //user entered ID matches on from accountList { accountList[i].Password = CaesarCipher.encrypt(inPass, PASS_KEY); //update password for that ID resultListBox.Items.Add("Password for (ID: " + inID + ") has been updated"); //let user know password was updated break; //exit; work is done } } } else //password didnt pass reqs { passwordMessage(); } } else //ID was not found { resultListBox.Items.Add("Sorry, ID " + inID + " wasn't found!"); resultListBox.Items.Add(" "); } }
private void enterButton_Click(object sender, EventArgs e) { string encryptedUser = CaesarCipher.encrypt(passwordTxtBox.Text.ToString(), MASTER_PASS_KEY); //encrypt user input to compare if (encryptedUser.Equals(openFile())) //password match { mainForm.Show(); //show second form this.Visible = false; //hide this one } else //password didnt match { MessageBox.Show("You Entered The Wrong Password! (bestPasswordEver123)"); } }
/*************************************** * deleteDataWork(string, string ) * returns: true, if a user entered a ID and password that match an account ID/Password in accountList * otherwise, returns false * arguments: a string called checkPassword, the user entered password to search for * a string called CheckID, the user entered ID to search for * use: checks if the user entered a valid account ID/password ***************************************/ private bool deleteDataWork(string checkPassword, string checkID) { checkPassword = CaesarCipher.encrypt(checkPassword, PASS_KEY); //encrypt user entered password to search foreach (var account in accountList) //cycle thru accountList { if (checkID.Equals(account.IdNumber)) //found matching ID { if (checkPassword.Equals(account.Password)) //found matching password { return(true); } } } return(false); //matching password not found }
/********************************** * Makes sure what user entered (ID, Site, Password) is valid, * then add all that to a new object of the accountList * Displays messages as needed **********************************/ private void addNewDataButton_Click(object sender, EventArgs e) { string inID = IDNewDataTextBox.Text; //bring in text box data string inSite = siteNewDataTextBox.Text; string inPass = passwordNewDataTextBox.Text; if ((String.IsNullOrEmpty(inID)) || (String.IsNullOrEmpty(inSite))) //make sure no empty string for ID or site { resultListBox.Items.Add("No empty fields are allowed!"); resultListBox.Items.Add(" "); return; } if (!searchForID(inID)) //ID doesnt exist, continue { var tupleRes = searchDataWork(inSite); //only using the first return, which returns if site exists or not if (!tupleRes.Item1) //site doesnt exist, continue { if (passwordReqCheck(inPass)) //password passes reqs { accountList.Add(new Account(inID, inSite, CaesarCipher.encrypt(inPass, PASS_KEY))); //add new object to accountList resultListBox.Items.Add("Entry added!"); resultListBox.Items.Add(" "); } else //couldnt add password { passwordMessage(); } } else //site exists, dont continue { resultListBox.Items.Add("Sorry, site " + inSite + " already exists!"); resultListBox.Items.Add(" "); } } else //ID exists, dont continue { resultListBox.Items.Add("Sorry, ID " + inID + " already exists!"); resultListBox.Items.Add(" "); } }