Exemplo n.º 1
0
        public static List <PolicyPassword> ConvertPasswords(string[] passwords)
        {
            var list = new List <PolicyPassword>();

            foreach (string pass in passwords)
            {
                var policies     = Regex.Split(pass, @"\D+");
                var indexOfComma = pass.IndexOf(":");
                var policyLetter = pass.Substring(indexOfComma - 1, 1);
                var password     = pass.Split(" ")[2];
                var pp           = new PolicyPassword(policies, policyLetter.ToCharArray()[0], password);
                list.Add(pp);
            }

            return(list);
        }
Exemplo n.º 2
0
        private void ReadInput()
        {
            var input     = File.ReadAllLines(Environment.CurrentDirectory + "/Input/Input2.txt");
            var inputList = new List <PolicyPassword>();

            foreach (var line in input)
            {
                var p = new PolicyPassword();

                p.Min = Convert.ToInt32(line.Substring(0, line.IndexOf('-')));
                var lenTemp = line.IndexOf(' ') - 1 - line.IndexOf('-');
                p.Max      = Convert.ToInt32(line.Substring(line.IndexOf('-') + 1, lenTemp));
                lenTemp    = line.IndexOf(':') - 1 - line.IndexOf(' ');
                p.Letter   = line.Substring(line.IndexOf(' ') + 1, lenTemp);
                p.Password = line.Substring(line.IndexOf(':') + 2);

                inputList.Add(p);
            }

            policyPasswordList = inputList;
        }