Example #1
0
        public static bool ValidateOne(PasswordPolicyDTO passwordPolicy)
        {
            int count = 0;

            foreach (char letter in passwordPolicy.Password)
            {
                if (letter == passwordPolicy.Letter)
                {
                    count++;
                }
            }
            return(count >= passwordPolicy.Min && count <= passwordPolicy.Max);
        }
Example #2
0
        public static PasswordPolicyDTO Parse(string line)
        {
            var pwdPolicy = new PasswordPolicyDTO();

            var valuesInit = line.Split((":").ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            var values = valuesInit[0].Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            pwdPolicy.Letter = values[1].ToCharArray()[0];

            values        = values[0].Split("-".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            pwdPolicy.Min = int.Parse(values[0]);
            pwdPolicy.Max = int.Parse(values[1]);

            pwdPolicy.Password = valuesInit[1].Trim();
            return(pwdPolicy);
        }
Example #3
0
 public static bool ValidateTwo(PasswordPolicyDTO passwordPolicy)
 {
     return(passwordPolicy.Password[passwordPolicy.Min - 1] == passwordPolicy.Letter ^ passwordPolicy.Password[passwordPolicy.Max - 1] == passwordPolicy.Letter);
 }