public IActionResult GetWithCriteria([FromQuery] int length, [FromQuery] bool lowerCase, [FromQuery] bool upperCase, [FromQuery] bool numbers, [FromQuery] bool symbols, [FromQuery] bool multiPass)
        {
            PasswordRequirement passwordReq = new PasswordRequirement
            {
                Length            = length,
                IncludeLowercase  = lowerCase,
                IncludeUpperCase  = upperCase,
                IncludeNumbers    = numbers,
                IncludeSymbols    = symbols,
                MultiplePasswords = multiPass
            };
            string criteria = GetPasswordCriteria(passwordReq);

            if (passwordReq.Length > 0 && passwordReq.MultiplePasswords)
            {
                for (int i = 0; i < multiplePass; i++)
                {
                    passList.Add(GeneratePassword(criteria, passwordReq.Length));
                }
            }
            else if (passwordReq.Length > 0)
            {
                passList.Add(GeneratePassword(criteria, passwordReq.Length));
            }

            return(new JsonResult(passList));
        }
        private string GetPasswordCriteria(PasswordRequirement passwordReq = null)
        {
            string criteria = "";

            if (passwordReq != null)
            {
                if (passwordReq.IncludeLowercase)
                {
                    criteria += alphabets;
                }

                if (passwordReq.IncludeUpperCase)
                {
                    criteria += alphabets.ToUpper();
                }

                if (passwordReq.IncludeNumbers)
                {
                    criteria += numbers;
                }

                if (passwordReq.IncludeSymbols)
                {
                    criteria += symbols;
                }
            }
            else
            {
                criteria += alphabets + alphabets.ToUpper() + numbers + symbols;
            }

            return(criteria);
        }
        public void Test()
        {
            var fallback = new PasswordRequirement(0, PasswordService.AlphaChars);
            var settings = new PasswordSettings();
            var passwordLength = 20;
            var reqs = new[]
                           {
                               new PasswordRequirement(settings.MinimumNonAlphaChars, settings.MaximumNonAlphaChars, settings.IsUsKeyboard ? PasswordService.UsKeyboardNonAlphas : PasswordService.NonAlphas),
                               new PasswordRequirement(settings.MinimumUpperCase, settings.MaximumUpperCase, PasswordService.UpperAlphaChars),
                               new PasswordRequirement(settings.MinimumDigits, settings.MaximumDigits, PasswordService.DigitChars)
                           };
            var passwordService = new PasswordService();
            byte[] password = passwordService.GeneratePassword(passwordLength, fallback, reqs);

            Assert.NotNull(password);
            Assert.Equal(passwordLength, password.Length);

            foreach (PasswordRequirement req in reqs)
            {
                Assert.Equal(req.Required, req.Used);
            }
        }