Пример #1
0
        public static bool IsPasswordValid(PasswordInfo passwordInfo)
        {
            var letterCount =
                passwordInfo
                .StoredPassword
                .Count(letter => letter == passwordInfo.RepeatingLetter);

            return(letterCount <= passwordInfo.RangeTo && letterCount >= passwordInfo.RangeFrom);
        }
Пример #2
0
        public static bool IsPasswordReallyValid(PasswordInfo passwordInfo)
        {
            var isNeededLetterAtFirstPosition =
                passwordInfo.StoredPassword[passwordInfo.RangeFrom - 1] == passwordInfo.RepeatingLetter;
            var isNeededLetterAtSecondPosition =
                passwordInfo.StoredPassword[passwordInfo.RangeTo - 1] == passwordInfo.RepeatingLetter;

            return((isNeededLetterAtFirstPosition && !isNeededLetterAtSecondPosition) ||
                   (isNeededLetterAtSecondPosition && !isNeededLetterAtFirstPosition));
        }