Ejemplo n.º 1
0
        public static string GetPassword(PasswordRequirements requirement)
        {
            if (!CheckPasswordReuirements(requirement))
            {
                throw new InvalidOperationException("Wrong password requirements");
            }

            var password = GetPassword(requirement.Length);

            while (CheckPassword(password, requirement))
            {
                password = GetPassword(requirement.Length);
            }

            return(password);
        }
Ejemplo n.º 2
0
 public static bool CheckPassword(string s, PasswordRequirements r) =>
 s.Length == r.Length &&
 CheckUpperCaseCount(s, r.UpperLettersCount) &&
 CheckDigitsCaseCount(s, r.DigitsCount) &&
 CheckNonLettersCount(s, r.NonLettersCount);
Ejemplo n.º 3
0
 public static bool CheckPasswordReuirements(PasswordRequirements r) => r.Length >= (r.UpperLettersCount + r.DigitsCount + r.NonLettersCount);