Пример #1
0
        private void UpdateControl()
        {
            int score = pwdStrength.GetPasswordScore();

            lbText.Text = pwdStrength.GetPasswordStrength();
            int x1 = score * 4;
            int x2 = x1 + 99;

            if (x2 >= 500)
            {
                x2 = 499;
            }
            Color clr1 = Colors[x1];
            Color clr2 = Colors[x2];

            if (brush != null)
            {
                brush.Dispose();
                brush = null;
            }
            brush = new LinearGradientBrush(
                new Point(0, 0),
                new Point(this.Width, this.Height),
                clr1,
                clr2);

            Refresh();
        }
Пример #2
0
        private void UpdateControl()
        {
            int score = pwdStrength.GetPasswordScore();

            LblPasswordStrength.Text = pwdStrength.GetPasswordStrength();
            int x1 = score * 4;
            int x2 = x1 + 99;

            if (x2 >= 500)
            {
                x2 = 499;
            }
            Color clr1 = Colors[x1];
            Color clr2 = Colors[x2];

            if (brush != null)
            {
                brush.Dispose();
                brush = null;
            }
            brush = new LinearGradientBrush(new Point(0, 0), new Point(200, 100), clr1, clr2);

            int    height = 100;
            int    width  = 200;
            Random r      = new Random();
            int    x      = r.Next(75);

            Bitmap   bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
            Graphics g   = Graphics.FromImage(bmp);

            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            g.Clear(Color.Orange);
            g.DrawRectangle(Pens.White, 1, 1, width - 3, height - 3);
            g.DrawRectangle(Pens.Gray, 2, 2, width - 3, height - 3);
            g.DrawRectangle(Pens.Black, 0, 0, width, height);
            g.DrawString("The Code Project", new Font("Arial", 12, FontStyle.Italic),
                         SystemBrushes.WindowText, new PointF(x, 50));

            MemoryStream MS = new MemoryStream();

            bmp.Save(MS, System.Drawing.Imaging.ImageFormat.Jpeg);
            //ImgPasswordStrength.ImageUrl = System.Drawing.Image.FromStream(MS);
            //ImageSource.FromStream(() => new MemoryStream(IRawData.IRawData));


            g.Dispose();
            bmp.Dispose();
        }
Пример #3
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);
        }
Пример #4
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", " ");
        }
Пример #5
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;
            }
        }
Пример #6
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()));
            }
        }