示例#1
0
        void ChangePass() //change the main key
        {
            string[] passwords = File.ReadAllLines(GlobalVariables.AppConfigLoc + "password.txt");
            foreach (string password in passwords)                                                 //read all encrypted passwords from file
            {
                _password = StringCipher.Decrypt(password, GlobalVariables.DecryptKey);            //decrypt password with old key
                _password = StringCipher.Encrypt(_password, textBoxNewKey.Text);                   //encrypt with new key
                PasswordCollection.Add(_password);                                                 //add new encypted password to string collection
            }
            File.WriteAllLines(GlobalVariables.AppConfigLoc + "password.txt", PasswordCollection); //write collection to file
            _password = File.ReadAllText(GlobalVariables.AppConfigLoc + "FTPpass.txt");            //read encrypted FTP pass
            _password = StringCipher.Decrypt(_password, GlobalVariables.DecryptKey);               //decrypt using old key
            _password = StringCipher.Encrypt(_password, textBoxNewKey.Text);                       //encrypt using new kkey
            File.WriteAllText(GlobalVariables.AppConfigLoc + "FTPpass.txt", _password);            //write encrypted FTP pass to file

            _password = File.ReadAllText(GlobalVariables.AppConfigLoc + "pswdtest.txt");           //read encrypted test text
            _password = StringCipher.Decrypt(_password, GlobalVariables.DecryptKey);               //decrypt using old key
            _password = StringCipher.Encrypt(_password, textBoxNewKey.Text);                       //encrypt using new kkey
            File.WriteAllText(GlobalVariables.AppConfigLoc + "pswdtest.txt", _password);           //write encrypted FTP pass to file

            //_password = File.ReadAllText(GlobalVariables.AppConfigLoc + "custominfo.txt"); //read encrypted custom text
            //_password = StringCipher.Decrypt(_password, GlobalVariables.DecryptKey); //decrypt using old key
            // _password = StringCipher.Encrypt(_password, textBoxNewKey.Text); //encrypt using new kkey
            //File.WriteAllText(GlobalVariables.AppConfigLoc + "custominfo.txt", _password); //write encrypted custom info to file
            GlobalVariables.DecryptKey = textBoxNewKey.Text; //update new key to config
            MessageBox.Show("Pääsalasana vaihdettu!");       //display success message
            this.Close();
        }
示例#2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBoxPswd.Text == textBoxPswdAgain.Text) //check if passwords match
     {
         Properties.Settings.Default.Save();        //save settings
         using (File.Create(GlobalVariables.AppConfigLoc + "site.txt"))
             File.WriteAllText(GlobalVariables.AppConfigLoc + "pswdTest.txt", StringCipher.Encrypt("test", textBoxPswd.Text));
         Application.Restart();
     }
     else
     {
         MessageBox.Show("Salasanat eivät täsmää!");
     }
 }
示例#3
0
 private void ButtonSave_Click(object sender, EventArgs e)
 {
     //update site name
     Strings = File.ReadAllText(GlobalVariables.AppConfigLoc + "site.txt");
     Strings = Strings.Replace(OldSite, TextBoxSite.Text);
     File.WriteAllText(GlobalVariables.AppConfigLoc + "site.txt", Strings);
     //update username
     Strings = File.ReadAllText(GlobalVariables.AppConfigLoc + "username.txt");
     Strings = Strings.Replace(OldUsername, TextBoxUsername.Text);
     File.WriteAllText(GlobalVariables.AppConfigLoc + "username.txt", Strings);
     //update password
     Strings = File.ReadAllText(GlobalVariables.AppConfigLoc + "password.txt");
     Strings = Strings.Replace(OldencryptedPass, StringCipher.Encrypt(TextBoxPassword.Text, GlobalVariables.DecryptKey));
     File.WriteAllText(GlobalVariables.AppConfigLoc + "password.txt", Strings);
     this.Close();
 }
示例#4
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (RichTextBoxCustomInfo.Text == "")
     {
         RichTextBoxCustomInfo.Text = "Voit kirjoittaa tänne lisätietoja salasanasa..";
     }
     if (oldtext != RichTextBoxCustomInfo.Text)
     {
         if (MessageBox.Show("Olet tehnyt muutoksia tekstiin, haluatko tallentaa?", "Tallenna muutokset?", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             Info    = StringCipher.Encrypt(RichTextBoxCustomInfo.Text, GlobalVariables.DecryptKey);
             Strings = File.ReadAllText(GlobalVariables.AppConfigLoc + "custominfo.txt"); //replace username
             Strings = Strings.Replace(Encrypted, Info);
             File.WriteAllText(GlobalVariables.AppConfigLoc + "custominfo.txt", Strings);
         }
     }
     this.Close();
 }
示例#5
0
        void UpdateInfo()
        {
            if (TextBoxUsername.Text != "" && TextBoxPassword.Text != "")
            {
                if (Username != TextBoxUsername.Text || Password != TextBoxPassword.Text)
                {
                    if (MessageBox.Show("Olet tehnyt muutoksia käyttäjänimeent/salasanaan, haluatko tallentaa? \n" + Username + "=" + TextBoxUsername.Text + "\n" + Password + "=" + TextBoxPassword.Text, "Tallenna muutokset?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Strings = File.ReadAllText(GlobalVariables.AppConfigLoc + "username.txt"); //replace username
                        Strings = Strings.Replace(Username, TextBoxUsername.Text);
                        File.WriteAllText(GlobalVariables.AppConfigLoc + "username.txt", Strings);

                        Strings = File.ReadAllText(GlobalVariables.AppConfigLoc + "password.txt");
                        Strings = Strings.Replace(EncryptedPassword, StringCipher.Encrypt(TextBoxPassword.Text, GlobalVariables.DecryptKey));
                        File.WriteAllText(GlobalVariables.AppConfigLoc + "password.txt", Strings);
                    }
                }
            }
        }
示例#6
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();
            }
        }
示例#7
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();
 }