【问题标题】:Password strength [closed]密码强度[关闭]
【发布时间】:2011-08-26 05:44:25
【问题描述】:

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

他们给出了关于不同密码的完全不同的结果。不知何故,用位来衡量是很明显的,但是很难说出要考虑多少不同的字符,例如:

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

【问题讨论】:

  • 一些密码检查器也会测试字典中的单词。有时省略一个字母并使用较短的密码比字典中出现的较长密码更强大。

标签: passwords bit


【解决方案1】:

只需根据建议密码的某些特征打分即可:

  • 密码中每个字符1分
  • 如果同时使用数字和字符,则 2 分,如果还包含非数字或字符符号,则 3 分。
  • 如果它同时包含大写和小写字母,则 2 分。
  • 字典中可以找到的每个单词 -2 分(虽然这可能更难检查)。
  • -2 分,如果一个数字可以代表一年。

据此,举一些好密码和坏密码的例子,并了解什么是好分数。

【讨论】:

    【解决方案2】:

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

    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。

    如果你愿意,我可以发布所有的支持功能。

    干杯

    【讨论】:

      猜你喜欢
      • 2010-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-03
      • 2012-05-31
      • 2011-01-05
      • 2013-01-12
      相关资源
      最近更新 更多