コード例 #1
0
 public void BruteForceCardinalityTest()
 {
     Assert.AreEqual(26, PasswordScoring.PasswordCardinality("asdf"));
     Assert.AreEqual(26, PasswordScoring.PasswordCardinality("ASDF"));
     Assert.AreEqual(52, PasswordScoring.PasswordCardinality("aSDf"));
     Assert.AreEqual(10, PasswordScoring.PasswordCardinality("124890"));
     Assert.AreEqual(62, PasswordScoring.PasswordCardinality("aS159Df"));
     Assert.AreEqual(33, PasswordScoring.PasswordCardinality("!@<%:{$:#<@}{+&)(*%"));
     Assert.AreEqual(100, PasswordScoring.PasswordCardinality("©"));
     Assert.AreEqual(95, PasswordScoring.PasswordCardinality("ThisIs@T3stP4ssw0rd!"));
 }
コード例 #2
0
 public void PasswordScoringPasswordCardinalityScoresCorrectly(string password, int score)
 {
     PasswordScoring.PasswordCardinality(password).Should().Be(score);
 }
コード例 #3
0
 private double CalculateEntropy(string match)
 {
     return(Math.Log(PasswordScoring.PasswordCardinality(match) * match.Length, 2));
 }