devxlogo

Generate Random Passwords

Generate Random Passwords

Use the following method to generate random passwords.

private string GenerateRandomPassword(int minLength, int maxLength) {    StringBuilder randomPassword = new StringBuilder();    Random rand = new Random((int)DateTime.Now.Ticks);   int  randLength = rand.Next(minLength, maxLength);    for (int i = 0; i     {         int charint = 0;          while (charint == 0)              charint = rand.Next(48, 58);          randomPassword.Append((char)charint); } return randomPassword.ToString();   }}
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist