-2

I want to make an password list generator app I not found anything about generate 1000 password at a time most youtube videos generating 1 password

sample code

int minLength = 15;
int maxLength = 15;

string charavailalbe = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

StringBuilder password = new StringBuilder();
Random random = new Random();
int passwordLength = random.Next(minLength, maxLength + 1);

while (passwordLength-- > 0)
{  
    password.Append(charavailalbe[random.Next(charavailalbe.Length)]);
}
listBox1.Items.Add(password.ToString());
ˈvɔlə
  • 9,204
  • 10
  • 63
  • 89
yusuf
  • 7
  • 2
  • 2
    You need [a loop](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/iteration-statements). Take care to define `random` *outside* the loop (to avoid using the same seed for multiple passwords), and, while you're at it, remove `Random` and [use a secure cryptographic random number generator instead](https://stackoverflow.com/q/54991/87698). – Heinzi Apr 30 '22 at 15:13
  • 6
    And yes, it always scares me a bit to see security-critical code developed by people who still struggle to grasp the very basics of the programming language they use (no offense meant)... – Heinzi Apr 30 '22 at 15:16

1 Answers1

0

If you want to generate 1000 passwords, put your code inside a for-loop wich executes 1000 times.

for (int i = 0; i < 1000; i++)
{
    // generate a password and add the resulting password to your listBox1
}

You probably should put your password generation code inside a method, so you only need to call the method inside the for loop.

ˈvɔlə
  • 9,204
  • 10
  • 63
  • 89