Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            Form3 GenerateRandomPassword = new Form3();

            GenerateRandomPassword.Show();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            genNum     = string.Empty; alphabetLower = string.Empty; alphabetUpper = string.Empty; specialChars = string.Empty; Pwd = string.Empty;
            LengthPass = 0;
            // Generate Numbers Function
            String GenNumbers(int min, int max)
            {
                genNum = Convert.ToString(random.Next(min, max));
                return(genNum);
            }

            //Generate Capitals Function
            String GenAlphabetsUpper(int min, int max)
            {
                alphabetUpper = Convert.ToString(Convert.ToChar(random.Next(min, max)));
                return(alphabetUpper);
            }

            //Generate Smalls Functions
            String GenAlphabetsLower(int min, int max)
            {
                alphabetLower = Convert.ToString(Convert.ToChar(random.Next(min, max)));
                return(alphabetLower);
            }

            //Generate Special Function
            String GenSpecialChars(int min, int max)
            {
                int selctSpecialChar = (random.Next(min, max));

                if (selctSpecialChar == 0)
                {
                    specialChars = Convert.ToString(Convert.ToChar(random.Next(33, 47)));
                }
                else if (selctSpecialChar == 1)
                {
                    specialChars = Convert.ToString(Convert.ToChar(random.Next(58, 64)));
                }
                else if (selctSpecialChar == 2)
                {
                    specialChars = Convert.ToString(Convert.ToChar(random.Next(91, 96)));
                }
                else
                {
                    specialChars = Convert.ToString(Convert.ToChar(random.Next(123, 126)));
                }

                return(specialChars);
            }

            //input of user no. of charcters in password

            try
            {
                LengthPass = Convert.ToInt32(textBox2.Text);
            }
            catch
            {
                MessageBox.Show("Length Cannot Be Empty");
            }

            //FIRST CHARACTER CHARACTER CODE
            string latterPass = "", firstchara = "";

            if (LengthPass > 0)
            {
                if (radioButton1.Checked == true)
                {
                    firstchara = GenAlphabetsUpper(65, 90);
                }
                else if (radioButton2.Checked == true)
                {
                    firstchara = GenAlphabetsLower(97, 122);
                }
                else if (radioButton3.Checked == true)
                {
                    firstchara = GenNumbers(0, 9);
                }
            }
            //LATER CHARACTERS CODE
            string a, b, c, d;

            a = Convert.ToString(Convert.ToInt32(checkBox1.Checked));
            b = Convert.ToString(Convert.ToInt32(checkBox2.Checked));
            c = Convert.ToString(Convert.ToInt32(checkBox3.Checked));
            d = Convert.ToString(Convert.ToInt32(checkBox4.Checked));

            int choice = Convert.ToInt32(a + b + c + d);

            switch (choice)
            {
            case 0000:
                MessageBox.Show("Please Select Check Boxes You Require");
                break;

            case 0001:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    latterPass += GenSpecialChars(0, 3);
                }
                break;

            case 0010:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    latterPass += GenNumbers(0, 9);
                }
                break;

            case 0011:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 3);

                    if (multiple == 1)
                    {
                        latterPass += GenNumbers(0, 9);
                    }
                    else
                    {
                        latterPass += GenSpecialChars(0, 3);
                    }
                }
                break;

            case 0100:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    latterPass += GenAlphabetsLower(97, 122);
                }
                break;

            case 0101:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 3);
                    if (multiple == 1)
                    {
                        latterPass += GenAlphabetsLower(97, 122);
                    }
                    else
                    {
                        latterPass += GenSpecialChars(0, 3);
                    }
                }

                break;

            case 0110:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 3);

                    if (multiple == 1)
                    {
                        latterPass += GenAlphabetsLower(97, 122);
                    }
                    else
                    {
                        latterPass += GenNumbers(0, 9);
                    }
                }
                break;

            case 0111:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 4);
                    switch (multiple)
                    {
                    case 1:
                        latterPass += GenAlphabetsLower(97, 122);

                        break;

                    case 2:
                        latterPass += GenNumbers(0, 9);

                        break;

                    case 3:
                        latterPass += GenSpecialChars(0, 3);

                        break;
                    }
                }
                break;

            case 1000:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    latterPass += GenAlphabetsUpper(65, 90);
                }
                break;

            case 1001:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 3);

                    if (multiple == 1)
                    {
                        latterPass += GenAlphabetsUpper(65, 90);
                    }
                    else
                    {
                        latterPass += GenSpecialChars(0, 3);
                    }
                }
                break;

            case 1010:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 3);

                    if (multiple == 1)
                    {
                        latterPass += GenAlphabetsUpper(65, 90);
                    }
                    else
                    {
                        latterPass += GenNumbers(0, 9);
                    }
                }
                break;

            case 1011:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 4);
                    switch (multiple)
                    {
                    case 1:
                        latterPass += GenAlphabetsUpper(65, 90);

                        break;

                    case 2:
                        latterPass += GenNumbers(0, 9);

                        break;

                    case 3:
                        latterPass += GenSpecialChars(0, 3);

                        break;
                    }
                }
                break;

            case 1100:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 3);

                    if (multiple == 1)
                    {
                        latterPass += GenAlphabetsUpper(65, 90);
                    }
                    else
                    {
                        latterPass += GenAlphabetsLower(97, 122);
                    }
                }
                break;

            case 1101:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 4);
                    switch (multiple)
                    {
                    case 1:
                        latterPass += GenAlphabetsUpper(65, 90);

                        break;

                    case 2:
                        latterPass += GenAlphabetsLower(97, 122);

                        break;

                    case 3:
                        latterPass += GenSpecialChars(0, 3);

                        break;
                    }
                }
                break;

            case 1110:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 4);
                    switch (multiple)
                    {
                    case 1:
                        latterPass += GenAlphabetsUpper(65, 90);

                        break;

                    case 2:
                        latterPass += GenAlphabetsLower(97, 122);

                        break;

                    case 3:
                        latterPass += GenNumbers(0, 9);

                        break;
                    }
                }
                break;

            default:
                for (int i = 0; i < (LengthPass - 1); i++)
                {
                    int multiple = random.Next(1, 5);
                    switch (multiple)
                    {
                    case 1:
                        latterPass += GenAlphabetsUpper(65, 90);

                        break;

                    case 2:
                        latterPass += GenAlphabetsLower(97, 122);

                        break;

                    case 3:
                        latterPass += GenNumbers(0, 9);

                        break;

                    case 4:
                        latterPass += GenSpecialChars(0, 3);
                        break;
                    }
                }

                break;
            }
            Pwd = firstchara + latterPass;
            if (Convert.ToBoolean(LengthPass))
            {
                Form4 GeneratedPassword = new Form4(Pwd);
                GeneratedPassword.Show();
                Pwd = string.Empty;
            }
            else
            {
                Form3 gn = new Form3();
            }
        }
Beispiel #3
0
        private void Button3_Click(object sender, EventArgs e)
        {
            Form3 form3 = new Form3();

            form3.Show();
        }
Beispiel #4
0
        private void ortalamaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 ortalamaformu = new Form3();

            ortalamaformu.ShowDialog();
        }
Beispiel #5
0
        //Переход на форму (3) с полями для внесения инофрмации;
        private void button2_Click(object sender, EventArgs e)
        {
            Form3 frm3 = new Form3(this);

            frm3.Show();
        }
Beispiel #6
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            var Setup = new Form3();

            Setup.Show();
        }
Beispiel #7
0
 public Form2()
 {
     f3 = new Form3();
     f3.Show();
     InitializeComponent();
 }
Beispiel #8
0
        private void button3_Click(object sender, EventArgs e)
        {
            Form3 newForm = new Form3();

            newForm.Show();
        }