コード例 #1
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));
    }
コード例 #2
0
        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);
        }