public ActionResult RegisterUser(LoginModel loginModel)
        {
            if (!ModelState.IsValid)
                return View(loginModel);

           
            var validationService = new PasswordValidationService();

            if (loginModel.Password != loginModel.ConfirmPassword)
            {
                ModelState.AddModelError("Password", "As senhas não conferem");
                return View(loginModel);
            }

            if (validationService.MeasurePasswordStrength(loginModel.Password) < 100)
            {
                ModelState.AddModelError("Password", "Senha não considerada forte. Por favor, coloque uma nova senha");
                return View(loginModel);
            }

            loginModel.Password = _desEncryptor.Encrypt(loginModel.Password);
            loginModel.ConfirmPassword = _desEncryptor.Encrypt(loginModel.ConfirmPassword);

            _repository.Save(loginModel);

            return RedirectToAction("Index", "Home");
        }
        public string Generate(int length, ValidationType validationType)
        {
            var passwordValidation = new PasswordValidationService();

            var wordChar = GenerateChars(length, validationType);
            var word = new String(wordChar);
            var measuredPasswordStrength = passwordValidation.MeasurePasswordStrength(word);

            if (validationType == ValidationType.Strong)
                while (measuredPasswordStrength != 100)
                {
                    wordChar = GenerateChars(length, validationType);
                    word = new String(wordChar);
                    measuredPasswordStrength = passwordValidation.MeasurePasswordStrength(word);
                }
            else if (validationType == ValidationType.Medium)
                while (measuredPasswordStrength != 50)
                {
                    wordChar = GenerateChars(length, validationType);
                    word = new String(wordChar);
                    measuredPasswordStrength = passwordValidation.MeasurePasswordStrength(word);
                }
            else if (validationType == ValidationType.Weak)
                while (measuredPasswordStrength != 20)
                {
                    wordChar = GenerateChars(length, validationType);
                    word = new String(wordChar);
                    measuredPasswordStrength = passwordValidation.MeasurePasswordStrength(word);
                }

            return word ;
        }
        public override bool IsValid(object value)
        {
            const double maxPasswordStrength = 100;

            var validationService = new PasswordValidationService();
            return validationService.MeasurePasswordStrength((string)value) == maxPasswordStrength;
        }
        public IHttpActionResult Get(string word)
        {
            var validation = new PasswordValidationService();
            var response  = validation.MeasurePasswordStrength(word);

            return Ok(response);
        }
 public void Init()
 {
     _passwordGenerator = new PasswordGenerateService();
     _passwordValidationService = new PasswordValidationService();
 }