示例#1
0
        // Verify that the user has entered the correct master password.
        public static void Authenticate(TextBox passTextBox, Button loginButton, Label statusLabel, Label infoLabel, TabControl tabControl, ListView passwordListView)
        {
            statusLabel.Text = "Authenticating your master password";



            // Prevent multiple login attempts at once.
            loginButton.Enabled = false;
            tControl            = tabControl;
            accountLoginButton  = loginButton;
            string masterPassword     = passTextBox.Text;
            string masterPasswordHash = File.ReadAllText(PIMUX_AUTH);


            // Start a background thread to verify password.
            // Background thread is used due to intensivity of Argon2i.
            new Thread(() => {
                Thread.CurrentThread.IsBackground = true;
                if (PasswordHash.ArgonHashStringVerify(masterPasswordHash, masterPassword))
                {
                    // Correct master password.
                    statusLabel.Invoke((MethodInvoker)(() => statusLabel.Text = ""));
                    tabControl.Invoke((MethodInvoker)(() => tabControl.SelectTab(2)));
                    passTextBox.Invoke((MethodInvoker)(() => passTextBox.Text = ""));
                    PasswordManage pm = new PasswordManage(masterPassword, infoLabel, passwordListView);
                }
                else
                {
                    // Incorrect master password.
                    statusLabel.Invoke((MethodInvoker)(() => statusLabel.Text = "Invalid master password"));
                    MessageBox.Show("Invalid master password");
                }
                loginButton.Invoke((MethodInvoker)(() => loginButton.Enabled = true));
            }).Start();
        }
示例#2
0
        private void SettingsForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Form is being closed, apply settings to setting file.
            // Get settings from form control values.
            string hidePasswordValue = Convert.ToString(HidePasswordsCheckBox.Checked);
            string timeoutValue      = Convert.ToString(SettingsTimeoutTextbox.Text);

            // Check timeout value is an integer.
            if (!timeoutValue.All(char.IsDigit))
            {
                MessageBox.Show("Timeout value must be an integer", "Error");
                return;
            }
            string timeoutEnabledValue = Convert.ToString(TimeoutCheckBox.Checked);
            string settingsConfig      = "HidePassword="******"Timeout=" + timeoutValue + Environment.NewLine +
                                         "TimeoutEnabled=" + timeoutEnabledValue;

            // Write settings to config file.
            File.WriteAllText(PIMUX_SETTINGS, settingsConfig);
            // Set new timeout time on watchdog.
            Watchdog.timeoutTime = GetTimeout();
            // Refresh passwords.
            PasswordManage.RefreshPasswords();
        }
示例#3
0
        // Add the new password.
        private void AddPasswordButton_Click(object sender, EventArgs e)
        {
            // Get password entry info.
            string username = NewPassUsernameTextbox.Text;
            string email    = NewPassEmailTextbox.Text;
            string website  = NewPassWebsiteTextbox.Text;
            string password = NewPassPasswordTextbox.Text;
            string notes    = NewPassNotesTextbox.Text;

            //string pin = NewPassPinTextbox.Text;
            //string phone = NewPassPhoneTextbox.Text;

            if (username == "" || email == "" || password == "" || website == "")
            {
                // One if the fields is missing.
                MessageBox.Show("At least one of the fields is empty.", "Missing field");
            }
            else
            {
                // Store the password entry.
                PasswordManage.StorePassword(username, email, password, website, notes);
                // Refresh displayed passwords.
                PasswordManage.RefreshPasswords();
                Close();
            }
        }
        private void SavePasswordButton_Click(object sender, EventArgs e)
        {
            // Create password entry.
            string passwordEntry = EditPassWebsiteTextbox.Text + Separator + EditPassUsernameTextbox.Text + Separator + EditPassEmailTextbox.Text + Separator + EditPassPasswordTextbox.Text + Separator + EditPassNotesTextbox.Text; //+ Separator + EditPassPhoneTextbox.Text + Separator + EditPassPinTexbox.Text;

            // Update the password entry.
            PasswordManage.EditPasswordStore(rightClickedWebsiteRow, passwordEntry);
            Close();
        }
示例#5
0
        // Function to copy items to the system clipboard.
        private void CopyMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            // Handle menu item clicked.
            ToolStripItem item = e.ClickedItem;
            // Copy password to clipboard.
            string returnedValue = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, item.Text);

            Clipboard.SetText(returnedValue);
        }
示例#6
0
        // Function to show / hide displayed passwords.
        private void ShowToolStripMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            // Handle menu item clicked.
            ToolStripItem item = e.ClickedItem;

            if (item.Text == "Show")
            {
                // Allow showing of one password at once.
                PasswordManage.RefreshPasswords();
                PasswordManage.ShowPassword(rightClickedWebsiteRow);
            }
            else if (item.Text == "Hide")
            {
                // Hide password.
                PasswordManage.RefreshPasswords();
            }
        }
示例#7
0
        // Function to handle clicks on context menu strip.
        private void ContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            // Handle menu item clicked.
            ToolStripItem item = e.ClickedItem;

            if (item.Text == "Delete")
            {
                // Confirm user wants to delete password entry.
                string website = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Website");
                if (MessageBox.Show("Are you sure you want to delete this password entry for " + website + "?", "Confirm deletion", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    // Delete the password entry.
                    PasswordManage.RemovePasswordEntry(rightClickedWebsiteRow);
                }
            }
            else if (item.Text == "Edit")
            {
                // Get desired password entry data.
                string username = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Username");
                string email    = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Email");
                string website  = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Website");
                string password = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Password");
                string notes    = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Notes");
                string pin      = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "PIN");
                string phone    = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Phone");

                // Update text boxes. And pass in right clicked website row.
                EditPasswordEntryForm editPasswordForm = new EditPasswordEntryForm();
                editPasswordForm.UpdateTextBoxes(username, email, website, password, notes, rightClickedWebsiteRow);
                // Show edit form.
                editPasswordForm.ShowDialog();
            }
            else if (item.Text == "Show notes")
            {
                // Show the notes for the password.
                string notes = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Notes");
                MessageBox.Show(notes, "Notes");
            }
        }