mardi 7 juillet 2020

Have finished this beauty [closed]

I have finished this program have found a way to loop . This isnt actually a question but I will post the code for whoever who want to try it out and post some screenshots as well.

List<string> characters = new List<string>();

    List<string> passwords = new List<string>();

    string rip = "";

    int size = 0;

    int maxr = 0;

    int currentprogress = 0;

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        SetList();
    }

    public void SetList()
    {
        string[] numbers = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

        string[] lowercase = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };

        string[] uppercase = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };

        characters.AddRange(numbers);

        characters.AddRange(lowercase);

        characters.AddRange(uppercase);
    }
    public void Generate()
    {


      




            int x = 1;

            Random rand = new Random();

            while (x <= size)
            {
                int y = rand.Next(0, characters.Count - 1);

                string ch = characters[y];

                rip = rip + ch;

                x++;

            }
           

        if (!passwords.Contains(rip))
        {
            passwords.Add(rip);

      
        }

        
               
        rip = string.Empty;

        ResultsLabel.Text = passwords.Count.ToString() + "/" + maxr.ToString();

    }

    private void findPasswordsButton_Click(object sender, EventArgs e)
    {
        size = Convert.ToInt32(sizeSelect.Value);

        maxr = Convert.ToInt32(Math.Pow(58, size));



        timerStartStop.Start();
    }

    private void clearButton_Click(object sender, EventArgs e)
    {
        passwords.Clear();
    }

    private void showpasswordsButton_Click(object sender, EventArgs e)
    {
        showpasswordsListbox.Items.Clear();

      foreach(string password in passwords)
        {
            showpasswordsListbox.Items.Add(password);
        }
    }

    private void timerStartStop_Tick(object sender, EventArgs e)
    {
        if (passwords.Count != maxr)
        {
            Generate();

        }
    }

    private void stopfindingButton_Click(object sender, EventArgs e)
    {
        timerStartStop.Stop();
    }
}

enter image description here

enter image description here

Can't wait to read your comments! It took me several hours on the internet cafe ( and lots of money buying hours). Hmm if you want a 'private' comment just post an answer instead of commenting on the question.




Aucun commentaire:

Enregistrer un commentaire