C# – Random Password Generator – Video

I know a lot of people, having problems creating passwords. With the current code I will show you how to create a password using C#. The password consists of at least two capital letters, two small letters, a digit and three special characters. Furthermore, up to seven more chars are added, thus making its lenght a random between 8 and 15. Thus it is probably one of the best passwords ever, except for the fact it will be quite difficult for you to remember it.

Here is the code:

What is interesting in this code:

1. We have the variable “rnd” defined in the class, and not in the Main method, thus making it available for the whole class.

2. The Method GenerateChar() returns a random symbol. The method chooses a random position in a variety of symbols and returns the symbol of this position.

3. The method InsertAtRandomPosition() chooces a random position in the StringBuilder object and puts at this position a symbol.

Here is the video:

 

 

Disclaimer: The code is partially taken from the TelerikAcademy courses for programming & the free Bulgarian C# programming book.

You may find the exe file of this application here.