Exemplo n.º 1
0
        static PasswordComplexityLevel GetPasswordComplexityLevel(string password)
        {
            PasswordComplexity currentPassword = GetGivenPasswordComplexity(password);

            if (IsRequiredComplexPassword(currentPassword, GetHighPasswordComplexity()))
            {
                return(PasswordComplexityLevel.High);
            }
            else if (IsRequiredComplexPassword(currentPassword, GetMediumPasswordComplexity()))
            {
                return(PasswordComplexityLevel.Medium);
            }

            return(PasswordComplexityLevel.Low);
        }
Exemplo n.º 2
0
        private static bool IsRequiredComplexPassword(PasswordComplexity currentPassword, PasswordComplexity requiredComplex)
        {
            if (currentPassword.MinLowercaseChars < requiredComplex.MinLowercaseChars)
            {
                return(false);
            }

            if (currentPassword.MinUpercaseChars < requiredComplex.MinUpercaseChars)
            {
                return(false);
            }

            if (currentPassword.MinDigits < requiredComplex.MinDigits)
            {
                return(false);
            }

            if (currentPassword.MinSymbols < requiredComplex.MinSymbols)
            {
                return(false);
            }

            return(true);
        }