using System.Security.Cryptography;
public static void Main(string[] args)
bool validLength = false;
int userDefinedLength = 0;
Console.WriteLine("How many characters would you like your password to be?");
userDefinedLength = int.Parse(Console.ReadLine());
if (userDefinedLength < 3)
Console.WriteLine("Please enter something larger than 3.");
Console.WriteLine("Please input a valid integer length.");
} while (validLength == false);
char[] passwordArray = new char[userDefinedLength];
bool validPassword = false;
for (int i = 0; i < passwordArray.Length; i++)
randomAsc = PseudoRandom.Next(1, 4);
asciiValue = PseudoRandom.Next(65, 91);
asciiValue = PseudoRandom.Next(97, 123);
asciiValue = PseudoRandom.Next(48, 58);
asciiChar = (char)asciiValue;
passwordArray[i] = asciiChar;
for (int i = 0; i < passwordArray.Length; i++)
if (char.IsDigit(passwordArray[i]))
if (char.IsUpper(passwordArray[i]))
if (char.IsLower(passwordArray[i]))
if (isDigit == true && isUpper == true && isLower == true)
} while (validPassword == false);
Console.WriteLine("Your password is...");
foreach (char c in passwordArray)
public static class PseudoRandom
private static RNGCryptoServiceProvider global;
private static Random local;
private static Random Local
byte[] buffer = new byte[4];
int seed = BitConverter.ToInt32(buffer, 0);
random = local = new Random(seed);
global = new RNGCryptoServiceProvider();
public static int Next(int maxValue)
return Local.Next(maxValue);
public static int Next(int minValue, int maxValue)
return Local.Next(minValue, maxValue);
public static double NextDouble()
return Local.NextDouble();
public static double NextDouble(double maxValue)
return NextDouble(0.0, maxValue);
public static double NextDouble(double minValue, double maxValue)
return Local.NextDouble() * (maxValue - minValue) + minValue;