Skip to content

PasswordGenerator can generate strong cryptographic password.

Notifications You must be signed in to change notification settings

LusineHovs/PasswordGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PasswordGenerator

In Generator class you will find PasswordGenerator() method, by using this you can generate random passwords with uppercase/lowercase letters, also numbers.

  • PasswordGenerator() method uses RNGCryptoServiceProvider class.
using (var rng = new RNGCryptoServiceProvider())
{
 var data = new byte[4];
 rng.GetBytes(data);
 var seed = BitConverter.ToInt32(data, 0);
 var rnd = new Random(seed);

 string password = string.Empty;

for (int i = 0; i < length; i++)
{
 if (rnd.Next(1, 4) == 1)
     password += (char)rnd.Next(48, 57);
 else if (rnd.Next(1, 4) == 2)
     password += (char)rnd.Next(65, 90);
 else
     password += (char)rnd.Next(97, 122);
}
 return password;
              

Using UserProgram class you can execute the program, simply write the required length of password you want to generate, instead of 10.

Console.WriteLine(Generator.PasswordGenerator(10));

#Keywords C# 6.0, .Net Framework 4.6, Microsoft Visual Studio.

About

PasswordGenerator can generate strong cryptographic password.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages