パスワードジェネレータに問題があります。
var listOfCharacters = "abcdefghijklmnopqrstuvwxyz"
chars = listOfCharacters.ToCharArray();
} // RB: I've reformatted the code, but left this brace in.
// I think it should be removed though...
string password = string.Empty;
for (int i = 0; i < length; i++) // length = 64
{
int x = random.Next(0, chars.Length); // chars.Lenght = 26
if (!password.Contains(chars.GetValue(x).ToString()))
password += chars.GetValue(x);
else
i--;
}
if (length < password.Length) password = password.Substring(0, length); //stucks here at 26 because all the 26 chars from the list are used one time so there are no more chars to use, but i want to use a char more than one time
return password;
私の問題は、64文字のパスワードを作成したいときに、例26の文字のリストを使用すると、リストから26文字すべてを1回だけ取得するため、26で生成を停止することです。上記のコードでは、1文字を複数取る方法が必要なので、各文字を1回だけでなく、例として、文字「a」を3回取ることができます。