2011-05-16 73 views
2

嘿, 我想知道如何最好地衡量密码强度。我发现了两个不同的网页: http://rumkin.com/tools/password/passchk.phphttp://www.passwordmeter.com/密码强度

,他们给有关不同的密码完全不同的结果。不知何故,很明显,要衡量一下,但比可能很难分辨要考虑多少个不同的字符,例如:

假设我的密码是aB *,比使用蛮力的人必须使用特殊字母,大写和小写字母,因此~60个不同的字符,即60^3个组合。 到目前为止感谢!

+2

一些密码检查器也将测试字典单词。有时省略一个字母并且使用较短的密码比在字典中出现的更长的密码更强。 – Adam 2011-05-16 07:37:20

回答

2

就奖励基础上,提出密码的某些特性得分:

  • 1点,如果
  • 2点,它采用数字和字符和3分中的密码,每一个字符,如果它包含非 - 数字或字符符号也。
  • 如果它包含大写和小写字母,则为2分。
  • 在词典中可以找到每个词的-2分(尽管这可能更难以检查)。
  • -2分如果一个数字可以代表一年。

从这里,通过一些好的和不好的密码的例子,了解一个好的分数会是什么。

1

这是我正在使用的计划,它似乎工作得很好。

Public Enum PasswordComplexityScore 
    BadPassword 
    MediumStrengthPassword 
    GoodPassword 
End Enum 

Public Function CalculatePasswordComplexity() As PasswordComplexityScore 

    Dim Score As Integer 

    'If the password matches the username then BadPassword 
    If Password = UserName Then 
     Return PasswordComplexityScore.BadPassword 
    End If 
    'If the password is less than 5 characters then TooShortPassword 
    If Password.Length < 5 Then 
     Return PasswordComplexityScore.BadPassword 
    End If 

    Score = Password.Length * 4 

    Score = Score + (CheckRepeatedPatterns(1).Length - Password.Length) 
    Score = Score + (CheckRepeatedPatterns(2).Length - Password.Length) 
    Score = Score + (CheckRepeatedPatterns(3).Length - Password.Length) 
    Score = Score + (CheckRepeatedPatterns(4).Length - Password.Length) 


    'If the password has 3 numbers then score += 5 
    If CountNumbers() >= 3 Then 
     Score = Score + 5 
    End If 

    'If the password has 2 special characters then score += 5 
    If CountSymbols() >= 2 Then 
     Score = Score + 5 
    End If 

    'If the password has upper and lower character then score += 10 
    If HasUpperAndLowerCharacters() Then 
     Score = Score + 10 
    End If 

    'If the password has numbers and characters then score += 15 
    If HasNumbersAndCharacters() Then 
     Score = Score + 10 
    End If 

    'If the password has numbers and special characters then score += 15 
    If CountNumbers() > 0 And CountSymbols() > 0 Then 
     Score = Score + 15 
    End If 

    'If the password has special characters and characters then score += 15 
    If CountLetters() > 0 And CountSymbols() > 0 Then 
     Score = Score + 15 
    End If 

    'If the password is only characters then score -= 10 
    If CountLetters() > 0 And CountNumbers() = 0 And CountSymbols() = 0 Then 
     Score = Score - 15 
    End If 


    'If the password is only numbers then score -= 10 
    If CountLetters() = 0 And CountNumbers() > 0 And CountSymbols() = 0 Then 
     Score = Score - 15 
    End If 

    If Score > 100 Then 
     Score = 100 
    End If 

    If Score < 34 Then 
     Return PasswordComplexityScore.BadPassword 
    End If 

    If Score < 68 Then 
     Return PasswordComplexityScore.MediumStrengthPassword 
    End If 

    Return PasswordComplexityScore.GoodPassword 

End Function 

我一直在生产中使用这个现在大约8年。我想我把它从别人的Java脚本转换成vb6然后转换成vb.net。

如果需要,我可以发布所有支持功能。

干杯