Exemplo n.º 1
0
 /// <summary>
 /// This method run when load button clicked, this method loading keys file
 /// </summary>
 private void loadBT_Click(object sender, EventArgs e)
 {
     // If dialog from password is ok
     if (fileLoad.ShowDialog() == DialogResult.OK)
     {
         try
         {
             filePath = fileLoad.FileName;
             var            fileStream   = fileLoad.OpenFile();
             StreamReader   streamReader = new StreamReader(fileStream);
             var            password     = desControler.DESDecryption(streamReader.ReadLine());
             KeysFileLoader loader       = new KeysFileLoader(password);
             if (loader.ShowDialog() == DialogResult.OK)
             {
                 streamReader.Close();
                 MessageBox.Show("File loaded properly !", "Operation status", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Text = "KeysHolder - Current Load File [ " + filePath + " ] - Created by Norbert Lubaszka - Version 0.1";
                 KeysReader keysReader = new KeysReader(filePath);
                 keysObjects = keysReader.GetKeys();
                 RefreshView();
             }
             else if (loader.ShowDialog() == DialogResult.Abort)
             {
                 streamReader.Close();
                 MessageBox.Show("Wrong password !", "Error status", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 filePath = string.Empty;
                 return;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Some error while loading keys. \n Error code: " + ex.ToString(), "Error status", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// This method run when Show passwords button clicked
 /// </summary>
 private void showPassBT_Click(object sender, EventArgs e)
 {
     if (filePath != string.Empty)
     {
         StreamReader streamReader = new StreamReader(filePath);
         var          password     = desControler.DESDecryption(streamReader.ReadLine());
         streamReader.Close();
         KeysFileLoader loader = new KeysFileLoader(password);
         if (loader.ShowDialog() == DialogResult.OK)
         {
             dataDGV.Columns[2].Visible = true;
         }
         else
         {
             MessageBox.Show("Wrong password !", "Error status", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("First load or create keys file !", "Error status", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }