healthchecks
This commit is contained in:
@@ -5,8 +5,8 @@ public class PasswordGenerator : IPasswordGenerator
|
||||
public string Generate(int length, bool includeNumbers = true, bool includeMayus = true, bool includeMinus = true, bool includeSpecials = true)
|
||||
{
|
||||
const string numbers = "0123456789";
|
||||
const string mayus = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const string minus = "abcdefghijklmnopqrstuvwxyz";
|
||||
const string mayus = "ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZ";
|
||||
const string minus = "abcçdefghijklmnñopqrstuvwxyz";
|
||||
const string specials = "!@#$%^&*()_+[]{}|;:,.<>?";
|
||||
var characters = minus;
|
||||
if (includeNumbers) characters += numbers;
|
||||
@@ -19,6 +19,22 @@ public class PasswordGenerator : IPasswordGenerator
|
||||
{
|
||||
password[i] = characters[random.Next(characters.Length)];
|
||||
}
|
||||
|
||||
var positionPool = new List<int>();
|
||||
for (int i = 0; i < length; i++) positionPool.Add(i);
|
||||
var forcedRandomNumber = random.Next(0, positionPool.Count);
|
||||
positionPool.RemoveAt(forcedRandomNumber);
|
||||
var forcedRandomMayus = random.Next(0, positionPool.Count);
|
||||
positionPool.RemoveAt(forcedRandomMayus);
|
||||
var forcedRandomMinus = random.Next(0, positionPool.Count);
|
||||
positionPool.RemoveAt(forcedRandomMinus);
|
||||
var forcedRandomSpecial = random.Next(0, positionPool.Count);
|
||||
positionPool.RemoveAt(forcedRandomSpecial);
|
||||
|
||||
password[forcedRandomNumber] = numbers[random.Next(numbers.Length)];
|
||||
password[forcedRandomMayus] = mayus[random.Next(mayus.Length)];
|
||||
password[forcedRandomMinus] = minus[random.Next(minus.Length)];
|
||||
password[forcedRandomSpecial] = specials[random.Next(specials.Length)];
|
||||
return new string(password);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user