Example #1
0
    private void UpdateShannonEntropy(string pw)
    {
        double entropyInBits = EntropyCalcs.ShannonEntropy(pw);

        this.ShannonEntropy = $"{LocMan.Get("Shannon entropy:")} {entropyInBits.ToString("F2")} {LocMan.Get("bits")}";
        OnPropertyChanged(nameof(ShannonEntropy));
    }
Example #2
0
    private void UpdatePasswordEntropy(string pw)
    {
        int entropyInBits           = EntropyCalcs.CalcutePasswordEntropy(pw);
        PasswordSecurityLevel level = EntropyCalcs.GetPasswordSecurityLevel(entropyInBits);

        this.PasswordEntropy = $"{LocMan.Get("Password entropy:")} {entropyInBits} {LocMan.Get("bits")} ({level})";
        OnPropertyChanged(nameof(PasswordEntropy));
    }
        public void GetPasswordSecurityLevelTest()
        {
            // Arrange
            string first  = "cat";
            string second = "cat!24TBTB1214b!DF¤";

            // Act
            PasswordSecurityLevel securityLevelFirst  = EntropyCalcs.GetPasswordSecurityLevel(EntropyCalcs.CalcutePasswordEntropy(first));
            PasswordSecurityLevel securityLevelSecond = EntropyCalcs.GetPasswordSecurityLevel(EntropyCalcs.CalcutePasswordEntropy(second));

            // Assert
            Assert.AreEqual(PasswordSecurityLevel.Very_Weak, securityLevelFirst);
            Assert.AreNotEqual(securityLevelFirst, securityLevelSecond);
        }
        public void CalcutePasswordEntropyTest()
        {
            // Arrange
            string first  = "cat";
            string second = "cat";
            string third  = "Doggie";

            // Act
            int entropyFirst  = EntropyCalcs.CalcutePasswordEntropy(first);
            int entropySecond = EntropyCalcs.CalcutePasswordEntropy(second);
            int entropyThird  = EntropyCalcs.CalcutePasswordEntropy(third);

            // Assert
            Assert.AreEqual(entropyFirst, entropySecond);
            Assert.AreNotEqual(entropyFirst, entropyThird);
        }