I’m working on making my own password generator; and I want it to create passwords that contain numbers, lowercase-letters, and uppercase-letters.
I am writing the program in C#, using Visual Studio.
Say I use the code below:
Random Rand = new Random();
Char C = Convert.ToChar(Rand.Next(0x30, 0x5A));
How could I make my program check whether (C) is equal to a number or a uppercase-letter?
A better (and standard) way, is to create an ‘alphabet’ string of allowable characters and then generate a random index into the string, to select an allowable character.
Much better than first generating a random character and then checking if it is allowable.
Note the removed lowercase ‘l’ (looks like 1). You should remove any others such as zero versus ‘O’ possibly…or whatever your password rules allow)
Here’s an example of using this technique to generate random strings: