Random string generator

PHOTO EMBED

Fri Sep 24 2021 16:16:23 GMT+0000 (UTC)

Saved by @Felhan #c#

private static string CreateRandomPassword(int length = 15)  
{  
    // Create a string of characters, numbers, special characters that allowed in the password  
    string validChars = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*?_-";  
    Random random = new Random();  
  
    // Select one random character at a time from the string  
    // and create an array of chars  
    char[] chars = new char[length];  
    for (int i = 0; i < length; i++)  
    {  
        chars[i] = validChars[random.Next(0, validChars.Length)];  
    }  
    return new string(chars);  
}  
content_copyCOPY