SamKr
1/26/2015 - 10:41 AM

Random Password Generator

Random Password Generator

internal static string GetRandomString(int length = 8)
{
    if (length < 2) return string.Empty;
    var startLength = length - 1;

    const string validChars = "0123456789ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

    var chars = new char[startLength];
    for (var i = 0; i < startLength; i++) chars[i] = validChars[Variables.Rnd.Next(0, validChars.Length)];
    var ret = new string(chars);

    ret = $"{ret}{new Random().Next(1, 9)}";
    return ret;
}