1,105,286 Community Members

how to check password strength

Member Avatar
anonymousi
Newbie Poster
15 posts since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i wanted know the vb.net code that checks the password strength on the basis of length ,special characters ,both combined ,numeric,alpha-numeric....

>>contents of form may include:
>textbox for password
>label or progress bar or trackbar to tell the user the strength(good ,very >good,excellent,poor)


>button to execute commands...

Unhnd_Exception
Deleted Member
 
0
 

Its up to you to decide on how strong a password is.

This will tell you how many uppercase, lowercase, numbers, and non numbers are in the password. You'll have to decide on what percentage of each is a strong password.

Dim t As String = "kaSDk43##$%43"

 Dim upper As Integer
 Dim lower As Integer
 Dim numbers As Integer
 Dim other As Integer

 For i = 0 To t.Length - 1

    If Char.IsLetter(t(i)) Then
        If Char.IsUpper(t(i)) Then
            upper += 1
        Else
            lower += 1
        End If

    ElseIf Char.IsNumber(t(i)) Then
        numbers += 1

    Else
        other += 1

    End If
Next
Unhnd_Exception
Deleted Member
 
0
 

Heres a link of someone who decided how to measure password strength.

http://www.codeproject.com/KB/miscctrl/PasswordStrengthControl.aspx?display=Print

Member Avatar
anonymousi
Newbie Poster
15 posts since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

thank you..the code seems pretty easy...

Member Avatar
anonymousi
Newbie Poster
15 posts since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i have a doubt ....how will this code take input from textbox....

Member Avatar
codeorder
Postaholic
2,027 posts since Aug 2010
Reputation Points: 197 [?]
Q&As Helped to Solve: 390 [?]
Skill Endorsements: 10 [?]
 
0
 

I would use the _TextChanged Event.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Dim t As String = TextBox1.Text
        '// Remaining code here.
    End Sub
Member Avatar
anonymousi
Newbie Poster
15 posts since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

and the output if it should displayed in a label for example green for strong

Member Avatar
anonymousi
Newbie Poster
15 posts since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

and how to execute....cause theres no response for the event .the user should have an output

Member Avatar
codeorder
Postaholic
2,027 posts since Aug 2010
Reputation Points: 197 [?]
Q&As Helped to Solve: 390 [?]
Skill Endorsements: 10 [?]
 
0
 

Its up to you to decide on how strong a password is.

This will tell you how many uppercase, lowercase, numbers, and non numbers are in the password. You'll have to decide on what percentage of each is a strong password.

No one can decide for you what a "strong" password is.

You could add all the numbers up and depending on the total, set the color of your Label.
Not a very good approach, but a start.

Here is a code sample with a slightly modified version of Unhnd_Exception's code.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Dim t As String = TextBox1.Text
        Dim iUpper, iLower, iNumbers, iOther As Integer
        For i As Integer = 0 To t.Length - 1 '// Loop thru all Characters in TextBox1.Text
            If Char.IsLetter(t(i)) Then
                If Char.IsUpper(t(i)) Then : iUpper += 2 '// 2 Points for UpperCase.
                Else : iLower += 1 '// 1 Point for LowerCase.
                End If
            ElseIf Char.IsNumber(t(i)) Then : iNumbers += 3 '// 3 Points for #'s.
            Else : iOther += 5 '// 5 Points for Special Charaters.
            End If
        Next

        Dim iSetTotal As Integer = iUpper + iLower + iNumbers + iOther '// sum Total.
        If iSetTotal <= 5 Then Label1.BackColor = Color.Red '// if Less than 6.
        If iSetTotal > 5 AndAlso iSetTotal <= 10 Then Label1.BackColor = Color.Orange '// if Greater than 5 and less that 11.
        If iSetTotal > 10 Then Label1.BackColor = Color.Green '// if Greater than 10.
    End Sub
Unhnd_Exception
Deleted Member
 
0
 

Heres a simple color meter control.

add a new new class to your project.

paste this into the new class.

rebuild the solution.

You should be able to drag and drop it from the
toolbox.

give it a value 0 - 100

Public Class Class1 : Inherits Control

Private _Value As Integer

Property Value() As Integer
    Get
       Return _Value
    End Get
    Set(ByVal value As Integer)
       If value < 0 Then value = 0
       If value > 100 Then value = 100
  
       _Value = value
       Me.Invalidate()
   End Set
End Property

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    Dim linBrush As New System.Drawing.Drawing2D.LinearGradientBrush(Me.ClientRectangle, Color.Empty, Color.Empty, Drawing2D.LinearGradientMode.Horizontal)
    Dim colBlend As New System.Drawing.Drawing2D.ColorBlend

    colBlend.Colors = New Color() {Color.Red, Color.Yellow, Color.Green}
    colBlend.Positions = New Single() {0, 0.5, 1}

    linBrush.InterpolationColors = colBlend

    e.Graphics.FillRectangle(linBrush, New Rectangle(0, 0, Me.Width * (_Value / 100), Me.Height))

    linBrush.Dispose()
End Sub

End Class
Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
0
 
Member Avatar
FadyHarfouch
Newbie Poster
1 post since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

If you want here's a link to microsoft's password strength check library implemented in VB.Net

http://www.codeproject.com/KB/security/PwdCheck.aspx

Member Avatar
Netcode
Veteran Poster
1,049 posts since Jun 2009
Reputation Points: 33 [?]
Q&As Helped to Solve: 86 [?]
Skill Endorsements: 8 [?]
 
0
 

check here

Question Answered as of 2 Years Ago by Unhnd_Exception, codeorder, FadyHarfouch and 2 others
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: