예제 #1
0
        private static bool VerifyPasswordStrength(string pwd)
        {
            var pwdGen = new PwdGen();

            if (pwd.Length >= 8)
            {
                var cntSymbols = pwd.Count((c) => pwdGen.Symbols.Contains(c));
                var cntUpper   = pwd.Count((c) => pwdGen.UpperCharacters.Contains(c));
                var cntLower   = pwd.Count((c) => pwdGen.LowerCharacters.Contains(c));
                var cntDigits  = pwd.Count((c) => pwdGen.Digits.Contains(c));
                if (cntSymbols >= 1 && cntUpper >= 1 && cntLower >= 1 && cntDigits >= 1)
                {
                    return(true);
                }
            }
            return(false);
        }
 private bool Validate(PwdGen gen)
 {
     if (gen.Length < 4 || gen.Length > 40 ||
         gen.MinDigits + gen.MinSymbols + gen.MinLowerCharacters + gen.MinUpperCharacters > gen.Length ||
         gen.MinDigits < 0 || gen.MinSymbols < 0 || gen.MinLowerCharacters < 0 || gen.MinUpperCharacters < 0 ||
         gen.Symbols.Length == 0 && gen.Digits.Length == 0 && gen.UpperCharacters.Length == 0 && gen.LowerCharacters.Length == 0 ||
         gen.MinDigits == 0 && gen.MinSymbols == 0 && gen.MinLowerCharacters == 0 && gen.MinUpperCharacters == 0 ||
         gen.MinDigits > 0 && gen.Digits.Length == 0 ||
         gen.MinSymbols > 0 && gen.Symbols.Length == 0 ||
         gen.MinUpperCharacters > 0 && gen.UpperCharacters.Length == 0 ||
         gen.MinLowerCharacters > 0 && gen.LowerCharacters.Length == 0)
     {
         MessageBox.Show(Properties.Resources.ERROR_PWDGEN_INVALID_INPUT, Title, MessageBoxButton.OK, MessageBoxImage.Error);
         return(false);
     }
     return(true);
 }