2011-05-16 104 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。

如果需要,我可以發佈所有支持功能。

乾杯