public void Should_Return_Equal_Passwords_When_Passed_Hash_And_Salt_From_Original_Password() { // arrange var text = "abc"; var hasher = new PBKDF2Adapter(new HashSettings()); var pswd = hasher.CreatePassword(text); var pswd2 = hasher.CreatePassword(text, pswd.Salt.ToArray(), pswd.Hash.Count, pswd.Iterations); // act var result = pswd.IsEqualTo(pswd2); // assert result.ShouldBeTrue(); }
public void Should_Generate_A_New_Hash_Each_Time_CreatePassword_Is_Passed_Text() { // arrange var text = "abc"; var hasher = new PBKDF2Adapter(new HashSettings()); var pswd1 = hasher.CreatePassword(text); var pswd2 = hasher.CreatePassword(text); // act var hashesAreTheSame = pswd1.Hash.ToArray().IsEqualTo(pswd2.Hash.ToArray()); var passwordsAreSame = pswd1.IsEqualTo(pswd2); // assert hashesAreTheSame.ShouldBeFalse(); passwordsAreSame.ShouldBeFalse(); }