A simple way to generate the password
static string GenerateRandomPassword(int numberOfCharactersInPassword)
{
if (numberOfCharactersInPassword > 32)
{
throw new ArgumentException("A password of length more than 32 can't be generated");
}
string guidWithoutDashes = Guid.NewGuid().ToString("n");
Console.WriteLine("Guid without dashes :- "+ guidWithoutDashes);
var chars = new char[numberOfCharactersInPassword];
var random = new Random();
for (int i = 0; i < chars.Length; i++)
{
chars[i] = guidWithoutDashes[random.Next(guidWithoutDashes.Length)];
}
Console.WriteLine("Random password :- " + new string(chars));
return new string(chars);
}