Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WebJsonResponse ret = null;

            try
            {
                String p = Tools.Tool.TrataInjection(Request["password"]);

                PasswordStrength pwdcheck = new PasswordStrength();
                pwdcheck.SetPassword(p);

                Color cor = pwdcheck.GetStrengthColor();

                ret = new WebJsonResponse("#passwordStrength", "<label>" + MessageResource.GetMessage("password_strength") + "</label><div class=\"form-group-content\"><span>" + pwdcheck.GetPasswordStrength() + "</span><div class=\"bar\" style=\"background: rgb(" + cor.R + "," + cor.G + "," + cor.B + ")\"></div></div>");
            }
            catch (Exception ex)
            {
                Tools.Tool.notifyException(ex);
                throw ex;
            }


            if (ret != null)
            {
                ReturnHolder.Controls.Add(new LiteralControl(ret.ToJSON()));
            }
        }
Example #2
0
        public PasswordStrengthControl()
        {
            InitializeComponent();

            pwdStrength = new PasswordStrength();
            pwdStrength.SetPassword(" ");
            UpdateControl();
        }
Example #3
0
        private void TxtConfirm_Leave(object sender, EventArgs e)
        {
            pwdStrength.SetPassword(txtConfirm.Text);

            DataTable dt = pwdStrength.GetStrengthDetails();

            var pscore = pwdStrength.GetPasswordScore();

            var passStrength = pwdStrength.GetPasswordStrength();

            label6.Text = strengthChecker(pwdStrength.GetPasswordStrength());

            switch (label6.Text)
            {
            case "Very Weak":
                label6.BackColor = Color.Red;
                break;

            case "Weak":
                label6.BackColor = Color.Red;
                break;

            case "Good":
                label6.BackColor = Color.Green;
                break;

            case "Strong":
                label6.BackColor = Color.Green;
                break;

            case "Very Strong":
                label6.BackColor = Color.Green;
                break;

            default:
                break;
            }
        }
Example #4
0
        private void ComputeValues()
        {
            string password = tbPassword.Text;

            DeleteStrengthBar();



            if (string.IsNullOrEmpty(password))
            {
                lblStrength.Text      = "";
                lblLength.Text        = "Length:";
                lblCardinality.Text   = "Cardinality:";
                lblEntropy.Text       = "Entropy:";
                dgvDetails.DataSource = null;
                return;
            }

            lblLength.Text = $"Length: {password.Length}";

            int    cardinality;
            double entropy = PasswordEntropy.Compute(password, out cardinality);

            lblCardinality.Text = $"Cardinality: {cardinality}";
            lblEntropy.Text     = $"Entropy: {entropy:F1} bits";

            _strengthMeter.SetPassword(password);
            int       strengthValue = _strengthMeter.GetPasswordScore();
            string    strength      = _strengthMeter.GetPasswordStrength();
            DataTable details       = _strengthMeter.GetStrengthDetails();

            lblStrength.Text = $"{strength} ({strengthValue})";

            DisplayBar(strengthValue, strength);
            DisplayDetails(details);
        }
Example #5
0
        public PasswordCollectionItem(Password pPassword)
        {
            Password = pPassword.Text;
            if (_passwordStrengthMeter == null)
            {
                _passwordStrengthMeter = new PasswordStrength();
            }

            Length = Password.Length;

            _passwordStrengthMeter.SetPassword(Password);
            StrengthValue = _passwordStrengthMeter.GetPasswordScore();
            Strength      = _passwordStrengthMeter.GetPasswordStrength();

            int cardinality;

            Entropy = PasswordEntropy.Compute(Password, out cardinality);

            CombinedStrength = (long)(100.0 * Entropy + StrengthValue);

            Cardinality = cardinality;

            SepText = pPassword.TextDelimited.Replace("\t", " ");
        }
Example #6
0
 public void SetPassword(String pwd)
 {
     pwdStrength.SetPassword(pwd);
     UpdateControl();
 }
Example #7
0
        public PasswordStrengthControl()
        {
            InitializeComponent();

            pwdStrength = new PasswordStrength();
            pwdStrength.SetPassword(" ");
            UpdateControl();
        }