示例#1
0
        public static bool validPasswordPart1(ILogger log, PasswordSpec passwordSpec)
        {
            var occurrences = 0;

            for (var i = 0; i < passwordSpec.Password.Length; i++)
            {
                if (passwordSpec.Password[i] == passwordSpec.Letter)
                {
                    occurrences++;
                }
            }
            return(occurrences >= passwordSpec.FirstParameter && occurrences <= passwordSpec.SecondParameter);
        }
示例#2
0
 public static bool validPasswordPart2(ILogger logger, PasswordSpec passwordSpec)
 {
     return(passwordSpec.Password[passwordSpec.FirstParameter - 1] == passwordSpec.Letter
            ^ passwordSpec.Password[passwordSpec.SecondParameter - 1] == passwordSpec.Letter);
 }