Generate a random password

  • Homepage
  • Software
  • Thoughts and Ideas
  • Photos and Art
  • Contact

To generate a random password, you need to create an instance of RandomPasswordGenerator. You need to pass the character groups you want to use to the constructor. In the following example all character groups are to be used. So PasswordOptions.AllCharacters is passed to the constructor of the RandomPasswordGenerator class.

After that, you can call the method Generate of the RandomPasswordGenerator object to generate the password. This method takes the length of the password to be generated as parameter.

using CAM.PasswordGeneratorLibrary;
...
PasswordGenerator pwdGen = 
  new RandomPasswordGenerator(PasswordOptions.AllCharacters);

Console.WriteLine(pwdGen.Generate(8));
© Christoph A. Müller - Contact/Imprint - Privacy