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 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); }
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); }