Ejemplo n.º 1
0
        /*=================================================================================================
        *       CONSTANTS
        *================================================================================================*/
        /*PUBLIC******************************************************************************************/

        /*PRIVATE*****************************************************************************************/

        /*=================================================================================================
        *       FIELDS
        *================================================================================================*/
        /*PUBLIC******************************************************************************************/

        /*PRIVATE*****************************************************************************************/

        /*=================================================================================================
        *       PROPERTIES
        *================================================================================================*/
        /*PUBLIC******************************************************************************************/

        /*PRIVATE*****************************************************************************************/

        /*=================================================================================================
        *       CONSTRUCTORS
        *================================================================================================*/

        /*=================================================================================================
        *       PUBLIC METHODS
        *================================================================================================*/
        /*************************************************************************************************/
        public static PasswordComplexityLevel checkEffectiveBitSize(int passSize, string pass)
        {
            int charSet = 0;
            PasswordComplexityLevel passStrength = PasswordComplexityLevel.Weak;

            charSet = getCharSetUsed(pass);

            double result = Math.Log(Math.Pow(charSet, passSize)) / Math.Log(2);

            if (result <= 32)
            {
                passStrength = PasswordComplexityLevel.Weak;
            }
            else if (result <= 64)
            {
                passStrength = PasswordComplexityLevel.Mediocre;
            }
            else if (result <= 128)
            {
                passStrength = PasswordComplexityLevel.Ok;
            }
            else if (result > 128)
            {
                passStrength = PasswordComplexityLevel.Great;
            }

            return(passStrength);
        }
Ejemplo n.º 2
0
        /*************************************************************************************************/
        public void DisplayPasswordComplexity(PasswordComplexityLevel complexity)
        {
            switch (complexity)
            {
            case PasswordComplexityLevel.Weak:
                createPasswordTextBox.ForeColor = Color.Red;
                break;

            case PasswordComplexityLevel.Mediocre:
                createPasswordTextBox.ForeColor = Color.Orange;
                break;

            case PasswordComplexityLevel.Ok:
                createPasswordTextBox.ForeColor = Color.YellowGreen;
                break;

            case PasswordComplexityLevel.Great:
                createPasswordTextBox.ForeColor = Color.Green;
                break;

            default:
                createPasswordTextBox.ForeColor = Color.FromArgb(242, 242, 242);
                break;
            }
        }
Ejemplo n.º 3
0
        /*************************************************************************************************/
        private void CalculatePasswordComplexity(string password)
        {
            PasswordComplexityLevel passwordComplexityLevel = PasswordComplexityLevel.Weak;

            passwordComplexityLevel = PasswordComplexity.checkEffectiveBitSize(password.Length, password);

            _loginView.DisplayPasswordComplexity(passwordComplexityLevel);
        }
Ejemplo n.º 4
0
        /*=================================================================================================
        *       PUBLIC METHODS
        *================================================================================================*/
        /*************************************************************************************************/

        /*=================================================================================================
        *       PRIVATE METHODS
        *================================================================================================*/
        /*************************************************************************************************/
        private void PasswordTextChanged(string passwordText)
        {
            PasswordComplexityLevel passwordComplexityLevel = PasswordComplexityLevel.Weak;

            passwordComplexityLevel = PasswordComplexity.checkEffectiveBitSize(passwordText.Length, passwordText);

            _changePasswordView.DisplayPasswordComplexity(passwordComplexityLevel);
        }
Ejemplo n.º 5
0
        /*************************************************************************************************/
        public void DisplayPasswordComplexity(PasswordComplexityLevel complexity)
        {
            switch (complexity)
            {
            case PasswordComplexityLevel.Weak:
                passwordStrengthProgressBar.ForeColor = Color.Red;
                passwordStrengthProgressBar.BackColor = Color.Red;
                passwordStrengthProgressBar.Value     = 25;
                passwordStrengthLabel.Text            = "Weak";
                break;

            case PasswordComplexityLevel.Mediocre:
                passwordStrengthProgressBar.ForeColor = Color.Orange;
                passwordStrengthProgressBar.BackColor = Color.Orange;
                passwordStrengthProgressBar.Value     = 50;
                passwordStrengthLabel.Text            = "Mediocre";
                break;

            case PasswordComplexityLevel.Ok:
                passwordStrengthProgressBar.ForeColor = Color.YellowGreen;
                passwordStrengthProgressBar.BackColor = Color.YellowGreen;
                passwordStrengthProgressBar.Value     = 75;
                passwordStrengthLabel.Text            = "Ok";
                break;

            case PasswordComplexityLevel.Great:
                passwordStrengthProgressBar.ForeColor = Color.Green;
                passwordStrengthProgressBar.BackColor = Color.Green;
                passwordStrengthProgressBar.Value     = 100;
                passwordStrengthLabel.Text            = "Great";
                break;

            default:
                passwordStrengthProgressBar.ForeColor = Color.Red;
                passwordStrengthProgressBar.BackColor = Color.Red;
                passwordStrengthProgressBar.Value     = 1;
                passwordStrengthLabel.Text            = "Weak";
                break;
            }
        }