Display Password Strength!

J

jonesfranckandi

Hi everyone,

I know I am not much of a programmer but I managed to create a form
that changes admin password. Now What I want is to put a password
strength bar on my form. I want the strength to display weak, reliable
or strong depending on what the user has inputted has new password. I
wish the strength to be displayed as the user types. Can someone helps
me please!!!!.
Your help would be the most welcome!.
Thanks in advance!!!!!!!
 
M

ManningFan

Theorhetically, a password with all lower-case letters si weak, a
password with upper and lower-case letters is reliable and a password
that mixes upper case, lower case and numbers is strong. Of course
there's also the fact that any real word is less reliable than a
seemingly random mixture of letters and numbers (i.e. "Password1" is
less secure than "Passdord1").

So how do you quantify password strength? Well, if X <> ucase(X) then
it's not weak. You can also do a loop through an InStr(X) to see if
any of the values are numbers. It's definitely going to take a couple
of passes through a few different filters to determine the strength of
the password, but I think I've given you enough info to take a shot at
it.
 
J

jonesfranckandi

Thanks man.
But I am still have problems. can you be more explicit adn give me a
code example if possible please.
Tnaks in advance!!!!!
 
M

ManningFan

Well, if you want to do it as the user is typing the password, it's
near impossible to be perfect. You can't check to see if the password
is a real word unless you have a table with every word in the
dictionary. The best you can do is assume the password is weak. Then,
on the AfterUpdate event, check to see if the new character is
uppercase or a number. You can do that by using character strings (
Chr(X) ).

It's pretty difficult for a beginner, to be honest, and I don't have
time to write and test the code it would take to do it properly. I'm
sorry.
 
D

Daniel

ManningFan,

This is really rough code but should get you started

Dim strText As String
Dim strChr As String
Dim intCount As Integer
Dim a As Integer, b As Integer, c As Integer
Dim i As Integer, x As Integer, y As Integer

a = 0 'Numeric
b = 0 'lowercase
c = 0 'uppercase

strText = Me.Text0
intCount = Len(strText) 'counter

For i = 1 To intCount
strChr = Mid(strText, i, 1)
If IsNumeric(strChr) Then a = 1
For y = 65 To 90 'uppercase
If StrComp(strChr, Chr(y), vbBinaryCompare) = 0 Then c = 1
Next y
For x = 97 To 122 'lowercase
If StrComp(strChr, Chr(x), vbBinaryCompare) = 0 Then b = 1
Next x
Next i

If a + b + c = 3 Then
MsgBox "Password is strong"
Else
MsgBox "Your password is considered to be weak, please select a new
password"
End If

Daniel
 
J

jonesfranckandi

daniel, you are the man. it works fine. I managed to do a version
yesterday. I managed to figure some out. But your code is very straight
forward.
Man thanks again!!!!.
 
M

ManningFan

Any chance you can post your finished and tested code, just in case
someone else needs to do the same thing?
 
J

jonesfranckandi

yeh sure. I will do it as soon as I get at home.
ManningFan said:
Any chance you can post your finished and tested code, just in case
someone else needs to do the same thing?
 
J

jonesfranckandi

Here is the full and tested code. This code is a bit fancy but suits
what I wanted. Hope it will be of use.
Here it is:

Private Sub NewPassword_AfterUpdate()
Dim strText As String
Dim strChr As String
Dim intCount As Integer
Dim a As Integer, b As Integer, c As Integer
Dim i As Integer, x As Integer, y As Integer


a = 0 'Numeric
b = 0 'lowercase
c = 0 'uppercase


strText = Me.NewPassword
intCount = Len(strText) 'counter

For i = 1 To intCount
strChr = Mid(strText, i, 1)
If IsNumeric(strChr) Then a = 1
For y = 65 To 90 'uppercase
If StrComp(strChr, Chr(y), vbBinaryCompare) = 0 Then c = 1
Next y
For x = 97 To 122 'lowercase
If StrComp(strChr, Chr(x), vbBinaryCompare) = 0 Then b = 1
Next x
Next i

If intCount < 6 Then
Lblshort.Visible = True
Me.Txtfourth.Visible = False ' displays Too Short with progress bar
to light grey(Full)
Lblstrong.Visible = False
Lblweak.Visible = False
Me.Txtsixth.Visible = False
LblFair.Visible = False
Me.Txtsecond.Visible = False
LblGood.Visible = False
Me.Txtfirst.Visible = False
Else
If a + b + c = 3 Then
Lblshort.Visible = False 'displays Strong with progress bar to
green(Full)
Me.Txtfourth.Visible = True
Lblstrong.Visible = True
Lblweak.Visible = False
Me.Txtsixth.Visible = False
LblFair.Visible = False
Me.Txtsecond.Visible = False
LblGood.Visible = False
Me.Txtfirst.Visible = False
Else
If a + b = 2 Or a + c = 2 Then
Lblshort.Visible = False 'displays Good with progress bar
to dark Red (3/4 of original bar)
Me.Txtfourth.Visible = False
Lblstrong.Visible = False
Lblweak.Visible = False
Me.Txtsixth.Visible = False
LblFair.Visible = False
Me.Txtsecond.Visible = False
LblGood.Visible = True
Me.Txtfirst.Visible = True
Else
If b + c = 2 Then
Lblshort.Visible = False 'displays Fair with progress bar
to cyan (1/2 of original bar)
Me.Txtfourth.Visible = False
Lblstrong.Visible = False
Lblweak.Visible = False
Me.Txtsixth.Visible = False
LblFair.Visible = True
Me.Txtsecond.Visible = True
LblGood.Visible = False
Me.Txtfirst.Visible = False
Else
If a = 1 Or b = 1 Or c = 1 Then
Lblshort.Visible = False 'displays Weak with progress
bar to red(1/4 of original bar)
Me.Txtfourth.Visible = False
Lblstrong.Visible = False
Lblweak.Visible = True
Me.Txtsixth.Visible = True
LblFair.Visible = False
Me.Txtsecond.Visible = False
LblGood.Visible = False
Me.Txtfirst.Visible = False
End If
End If
End If
End If
End If
End Sub
 
M

ManningFan

Excellent job! I get psyched when people can push someone to a point
and that person can take it the rest of the way home. THAT'S HOW YOU
LEARN!

Big props to Daniel for the basic code, I was too burnt that day to
even give it a try.
 
Top