public void SuggestionsTest() { var zx = new Zxcvbn.Zxcvbn(new Zxcvbn.DefaultMatcherFactory()); for (int i = 0; i < testPasswords.Length; ++i) { var password = testPasswords[i]; var result = zx.EvaluatePassword(password); O(""); O("Password: {0}", result.Password); for (int j = 0; j < result.suggestions.Count(); ++j) { var realSuggestion = Utility.GetSuggestion(result.suggestions[j]); var expectedSuggestion = testSuggestions[i, j]; O("Suggestion: {0}", realSuggestion); O("Expected Suggestion: {0}", expectedSuggestion); Assert.AreEqual(realSuggestion, expectedSuggestion); } O(""); O("========================================="); } }
void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); return; } _instance = this; // DontDestroyOnLoad(this.gameObject); this.readTextAssetIntoList(this.easyBadPasswordsText, this.easyBadPasswords); this.readTextAssetIntoList(this.easyGoodPasswordsText, this.easyGoodPasswords); this.readTextAssetIntoList(this.mediumBadPasswordsText, this.mediumBadPasswords); this.readTextAssetIntoList(this.mediumGoodPasswordsText, this.mediumGoodPasswords); this.readTextAssetIntoList(this.hardBadPasswordsText, this.hardBadPasswords); this.readTextAssetIntoList(this.hardGoodPasswordsText, this.hardGoodPasswords); this.passwordChecker = new Zxcvbn.Zxcvbn(); }
public void WarningTest() { var zx = new Zxcvbn.Zxcvbn(new Zxcvbn.DefaultMatcherFactory()); for (int i = 0; i < testPasswords.Length; ++i) { var password = testPasswords[i]; var expectedWarning = testWarnings[i]; var result = zx.EvaluatePassword(password); var realWarning = Utility.GetWarning(result.warning); O(""); O("Password: {0}", result.Password); O("Warning: {0}", realWarning); O("Expected Warning: {0}", expectedWarning); O(""); O("========================================="); Assert.AreEqual(realWarning, expectedWarning); } }
public void RunAllTestPasswords() { var zx = new Zxcvbn.Zxcvbn(new Zxcvbn.DefaultMatcherFactory()); for (int i = 0; i < testPasswords.Length; ++i) { var password = testPasswords[i]; var result = zx.EvaluatePassword(password); O(""); O("Password: {0}", result.Password); O("Entropy: {0}", result.Entropy); O("Crack Time (s): {0}", result.CrackTime); O("Crack Time (d): {0}", result.CrackTimeDisplay); O("Score (0 to 4): {0}", result.Score); O("Calc time (ms): {0}", result.CalcTime); O("--------------------"); foreach (var match in result.MatchSequence) { if (match != result.MatchSequence.First()) { O("+++++++++++++++++"); } O(match.Token); O("Pattern: {0}", match.Pattern); O("Entropy: {0}", match.Entropy); if (match is Zxcvbn.Matcher.DictionaryMatch) { var dm = match as Zxcvbn.Matcher.DictionaryMatch; O("Dict. Name: {0}", dm.DictionaryName); O("Rank: {0}", dm.Rank); O("Base Entropy: {0}", dm.BaseEntropy); O("Upper Entpy: {0}", dm.UppercaseEntropy); } if (match is Zxcvbn.Matcher.L33tDictionaryMatch) { var lm = match as Zxcvbn.Matcher.L33tDictionaryMatch; O("L33t Entpy: {0}", lm.L33tEntropy); O("Unleet: {0}", lm.MatchedWord); } if (match is Zxcvbn.Matcher.SpatialMatch) { var sm = match as Zxcvbn.Matcher.SpatialMatch; O("Graph: {0}", sm.Graph); O("Turns: {0}", sm.Turns); O("Shifted Keys: {0}", sm.ShiftedCount); } if (match is Zxcvbn.Matcher.RepeatMatch) { var rm = match as Zxcvbn.Matcher.RepeatMatch; O("Repeat char: {0}", rm.RepeatChar); } if (match is Zxcvbn.Matcher.SequenceMatch) { var sm = match as Zxcvbn.Matcher.SequenceMatch; O("Seq. name: {0}", sm.SequenceName); O("Seq. size: {0}", sm.SequenceSize); O("Ascending: {0}", sm.Ascending); } if (match is Zxcvbn.Matcher.DateMatch) { var dm = match as Zxcvbn.Matcher.DateMatch; O("Day: {0}", dm.Day); O("Month: {0}", dm.Month); O("Year: {0}", dm.Year); O("Separator: {0}", dm.Separator); } } O(""); O("========================================="); Assert.AreEqual(expectedEntropies[i], result.Entropy); } }
public void RunAllTestPasswords() { var zx = new Zxcvbn.Zxcvbn(new Zxcvbn.DefaultMatcherFactory()); for (int i = 0; i < testPasswords.Length; ++i) { var password = testPasswords[i]; var result = zx.EvaluatePassword(password); O(""); O("Password: {0}", result.Password); O("Entropy: {0}", result.Entropy); O("Crack Time (s): {0}", result.CrackTime); O("Crack Time (d): {0}", result.CrackTimeDisplay); O("Score (0 to 4): {0}", result.Score); O("Calc time (ms): {0}", result.CalcTime); O("--------------------"); foreach (var match in result.MatchSequence) { if (match != result.MatchSequence.First()) O("+++++++++++++++++"); O(match.Token); O("Pattern: {0}", match.Pattern); O("Entropy: {0}", match.Entropy); if (match is Zxcvbn.Matcher.DictionaryMatch) { var dm = match as Zxcvbn.Matcher.DictionaryMatch; O("Dict. Name: {0}", dm.DictionaryName); O("Rank: {0}", dm.Rank); O("Base Entropy: {0}", dm.BaseEntropy); O("Upper Entpy: {0}", dm.UppercaseEntropy); } if (match is Zxcvbn.Matcher.L33tDictionaryMatch) { var lm = match as Zxcvbn.Matcher.L33tDictionaryMatch; O("L33t Entpy: {0}", lm.L33tEntropy); O("Unleet: {0}", lm.MatchedWord); } if (match is Zxcvbn.Matcher.SpatialMatch) { var sm = match as Zxcvbn.Matcher.SpatialMatch; O("Graph: {0}", sm.Graph); O("Turns: {0}", sm.Turns); O("Shifted Keys: {0}", sm.ShiftedCount); } if (match is Zxcvbn.Matcher.RepeatMatch) { var rm = match as Zxcvbn.Matcher.RepeatMatch; O("Repeat char: {0}", rm.RepeatChar); } if (match is Zxcvbn.Matcher.SequenceMatch) { var sm = match as Zxcvbn.Matcher.SequenceMatch; O("Seq. name: {0}", sm.SequenceName); O("Seq. size: {0}", sm.SequenceSize); O("Ascending: {0}", sm.Ascending); } if (match is Zxcvbn.Matcher.DateMatch) { var dm = match as Zxcvbn.Matcher.DateMatch; O("Day: {0}", dm.Day); O("Month: {0}", dm.Month); O("Year: {0}", dm.Year); O("Separator: {0}", dm.Separator); } } O(""); O("========================================="); Assert.AreEqual(expectedEntropies[i], result.Entropy); } }
/// <summary> /// <para>A static function to match a password against the default matchers without having to create /// an instance of Zxcvbn yourself, with supplied user data. </para> /// /// <para>Supplied user data will be treated as another kind of dictionary matching.</para> /// </summary> /// <param name="password">the password to test</param> /// <param name="userInputs">optionally, the user inputs list</param> /// <returns>The results of the password evaluation</returns> public static Result MatchPassword(string password, IEnumerable <string> userInputs = null) { var zx = new Zxcvbn(new DefaultMatcherFactory()); return(zx.EvaluatePassword(password, userInputs)); }
/// <summary> /// <para>A static function to match a password against the default matchers without having to create /// an instance of Zxcvbn yourself, with supplied user data. </para> /// /// <para>Supplied user data will be treated as another kind of dictionary matching.</para> /// </summary> /// <param name="password">the password to test</param> /// <param name="userInputs">optionally, the user inputs list</param> /// <returns>The results of the password evaluation</returns> public static Result MatchPassword(string password, IEnumerable<string> userInputs = null) { var zx = new Zxcvbn(new DefaultMatcherFactory()); return zx.EvaluatePassword(password, userInputs); }
public PwdSecurityManager() { RenewLogin = false; OperationStatus = PwdOperationStatus.Pending; StrengthCalculator = new Zxcvbn.Zxcvbn(); }