Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Could someone please enlighten me on what the best way to check password strength is?

 

The password in question must be at least 8 characters including at least 1 numeric and 1 non-alpha-numeric character.

 

I can compare the two passwords, but i dont know how to ensure each one is of a certain strength.

 

Thanks.

Posted
You should be able to use a RegularExpression, I can't tell you exactly what one that as I don't know much about them.
Anybody looking for a graduate programmer (Midlands, England)?
  • Leaders
Posted

You could skip the regular expressions and just do what seems to me to be the simplest thing: check for each quality that you want in a password. Check if it is 8 chars long, then check if it contains a number and a non-alphanumeric.

Function ValidatePassword(ByVal Password As String) As Boolean
   If Password.Length < 8 Then Return False
   'Too short

   Dim HasDigit As Boolean = False
   Dim HasNonAlphaNumeric As Boolean = False

   For Each c As Char In Password
      If Char.IsDigit(c) Then HasDigit = True
      If Not (Char.IsLetterOrDigit(c)) Then _
          HasNonAlphaNumeric = True
   Next

   Return HasDigit And HasNonAlphaNumeric
   'If it has both qualities, return true.
   'If not, the password is not strong enough.
End Function

For a really "strong" password, you could check to make sure that the password is not only eight characters long and has the two special characters, but also that it does not consist of only one normal (i.e. found in a dictionary) word and the special characters. In other words, remove the number and non-alphanumeric character, and compare with a dictionary (or spell checker). If you get a match from a dictionary, or a correctly spelled word from a spell checker, you have a mid-range strength password. If not, you have a very strong password.

[sIGPIC]e[/sIGPIC]
Posted

Marble, thanks for that. I was going to originally code it like that, but i didnt know how to check for non-alpha-numeric characters.

 

Kejpa...ermmm... thanks for that...lol... Unfortunately i dont speak Swedish :(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...