Esempio n. 1
0
        void CreatePassword()
        {
            bool writepass = true;

            if (textBoxOldPass.Text == "")                                                       //test if user wants to user existring password
            {
                password = CreatePassword(Convert.ToInt32(NumericUDlenght.Value));               //create password
                System.Threading.Thread.Sleep(10);
                if (password.Contains("@") && password.Contains("%") && password.Contains("#"))  //check if password is secure enough
                {
                    if (Properties.Settings.Default["AskIfPasswordIsGood"].ToString() == "True") //see if we should ask user about password?
                    {
                        if (MessageBox.Show("Salasana luotu: " + password + "\n Haluatko luoda uuden salasanan?", "Salasana luotu!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            writepass = false;
                            CreatePassword();
                        }
                    }
                }
                else
                {
                    writepass = false; //don't allow to save password
                    CreatePassword();  //try to create a more secure password
                }
            }
            else
            {
                password = textBoxOldPass.Text;                                                                                                                                                                     //Use existing password from textbox
            }
            if (writepass == true)                                                                                                                                                                                  //check if we should save changes
            {
                File.AppendAllText(GlobalVariables.AppConfigLoc + "password.txt", StringCipher.Encrypt(password, GlobalVariables.DecryptKey) + Environment.NewLine);                                                //add password to password text file
                File.AppendAllText(GlobalVariables.AppConfigLoc + "username.txt", TextBoxUsername.Text + Environment.NewLine);                                                                                      //add Username to text file
                File.AppendAllText(GlobalVariables.AppConfigLoc + "site.txt", TextBoxSiteName.Text + Environment.NewLine);                                                                                          //add site name to text file
                File.AppendAllText(GlobalVariables.AppConfigLoc + "custominfo.txt", StringCipher.Encrypt("Tänne voit lisätä salasanaan liittyviä lisätietoja!", GlobalVariables.DecryptKey) + Environment.NewLine); //add site name to text file
                this.Close();
            }
        }
Esempio n. 2
0
        void LoadUserDetails() // Load Username an Password to Textbox
        {
            if (testDecrypt == "test")
            { //
                try
                {
                    GlobalVariables.CurrentItem = ListboxSite.SelectedIndex;
                    Username          = File.ReadLines(GlobalVariables.AppConfigLoc + "username.txt").Skip(GlobalVariables.CurrentItem).Take(1).First();
                    EncryptedPassword = File.ReadLines(GlobalVariables.AppConfigLoc + "password.txt").Skip(GlobalVariables.CurrentItem).Take(1).First();
                    Password          = StringCipher.Decrypt(EncryptedPassword, GlobalVariables.DecryptKey);
                    Console.WriteLine(Username);
                    Console.WriteLine(Password);
                    TextBoxUsername.Text = Username;
                    TextBoxPassword.Text = Password;
                    site = ListboxSite.SelectedItem.ToString();
                    Console.WriteLine(site);
                    //change text to display username or email depending if username contains @ and .
                    if (Username.Contains("@") && Username.Contains("."))
                    {
                        label2.Text = "Sähköposti:";
                    }
                    else
                    {
                        label2.Text = "Käyttäjänimi:";
                    }

                    //settings test
                    if (Properties.Settings.Default["CopyClipboard"].ToString() == "True")
                    {
                        Clipboard.SetText(Password);
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Esempio n. 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     Properties.Settings.Default.Save(); // Saves settings in config file
     File.WriteAllText(GlobalVariables.AppConfigLoc + "FTPpass.txt", StringCipher.Encrypt(textBoxFTPpass.Text, GlobalVariables.DecryptKey));
     this.Close();
 }