Ejemplo n.º 1
0
        /*************************************
        * 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(" ");
            }
        }
Ejemplo n.º 2
0
        private void Form2_Load(object sender, EventArgs e)
        {
            loadList();

            Console.WriteLine("***** Here for grading only *****");
            foreach (var account in accountList)
            {
                Console.WriteLine(account.IdNumber + "->" + CaesarCipher.decrypt(account.Password, PASS_KEY));
            }
        }
Ejemplo n.º 3
0
        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)");
            }
        }
Ejemplo n.º 4
0
        /***************************************
        * 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
        }
Ejemplo n.º 5
0
        /***************************************************
        * When button is clicked will start a timer for 10 seconds,
        * sets passwords in listBox to be visible
        * *************************************************/
        private void viewPasswordButton_Click(object sender, EventArgs e)
        {
            resultListBox.Items.Clear();

            myTimer.Interval = 10000;                                                                              //for 10 second
            myTimer.Start();                                                                                       //start timer

            string inSite   = siteNameSearchDataTextBox.Text;                                                      //bring in site name
            var    tupleRes = searchDataWork(inSite);                                                              //store if site was found + index location

            if (tupleRes.Item1)                                                                                    //site was found, print info
            {
                resultListBox.Items.Add(accountList[tupleRes.Item2].IdNumber.PadRight(3)                           //print account info
                                        + (accountList[tupleRes.Item2].SiteName.PadRight(10))
                                        + (CaesarCipher.decrypt(accountList[tupleRes.Item2].Password, PASS_KEY))); //show password
            }
        }
Ejemplo n.º 6
0
        /**********************************
        * 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(" ");
            }
        }