コード例 #1
0
        private static PasswordPolicy1 ParseLine(string line)
        {
            var pass = new PasswordPolicy1();

            var split = line.Split();

            pass.Min      = Int32.Parse(split[0].Split("-")[0]);
            pass.Max      = Int32.Parse(split[0].Split("-")[1]);
            pass.Char     = split[1].Replace(":", "");
            pass.Password = split[2];

            return(pass);
        }
コード例 #2
0
        private static bool IsValid(PasswordPolicy1 passwordPolicy)
        {
            int charCount = passwordPolicy.Password.Length - passwordPolicy.Password.Replace(passwordPolicy.Char, "").Length;

            if (charCount < passwordPolicy.Min)
            {
                return(false);
            }

            if (charCount > passwordPolicy.Max)
            {
                return(false);
            }

            return(true);
        }