Beispiel #1
0
        /// <summary>
        /// Add password in vault
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                MyPassword myPassword = new MyPassword()
                {
                    UserName = textBoxMdpLogin.Text,
                    Password = textBoxMdpPassword.Text.ToSecureString(),
                    Data     = textBoxMdpData.Text,
                    Keyword  = textBoxMdpKeyword.Text
                };

                MyVault.Instance.Vault.Add(myPassword);

                RefreshList();

                textBoxMdpLogin.Text    = "";
                textBoxMdpPassword.Text = "";
                textBoxMdpData.Text     = "";
                textBoxMdpKeyword.Text  = "";

                MessageBox.Show(resources.GetString("labelMsgAddDone.Text"), resources.GetString("labelMsgAddDoneTitle.Text"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception except)
            {
                MessageBox.Show(except.ToString());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Raw data to MyPassword object
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static MyPassword From(String data)
        {
            String[]   values     = data.Split(new String[] { Environment.NewLine }, StringSplitOptions.None);
            MyPassword myPassword = new MyPassword()
            {
                Data     = values[0],
                UserName = values[1],
                Password = values[2].ToSecureString(),
                Keyword  = values[3]
            };

            return(myPassword);
        }
Beispiel #3
0
        /// <summary>
        /// Load file and fill passwords collection
        /// </summary>
        public void Load()
        {
            String pathFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), FILE_NAME);

            if (File.Exists(pathFile))
            {
                Vault.Clear();

                foreach (String data in File.ReadAllLines(pathFile))
                {
                    Vault.Add(MyPassword.From(Security.Instance.Decrypt(data)));
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Delete a password in vault
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteRowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (DataGridViewRow row in dataGridViewVault.SelectedRows)
                {
                    MyPassword selectedPwd = (MyPassword)row.DataBoundItem;
                    foreach (MyPassword mp in MyVault.Instance.Vault)
                    {
                        if (mp.ToStr() == selectedPwd.ToStr())
                        {
                            MyVault.Instance.Vault.Remove(mp);
                            break;
                        }
                    }
                }

                RefreshList();
            }
            catch (Exception except)
            {
                MessageBox.Show(except.ToString());
            }
        }