public void BCryptEmbededSalt() { var hasher = new BCryptHashProvider(); var original = Guid.NewGuid().ToString(); var password = $"{Guid.NewGuid()}{Guid.NewGuid()}"; var hashed = hasher.HashString(original, null); Assert.NotNull(hashed); var match = hasher.Verify(original, hashed, null); Assert.True(match); }
public void BCryptTrivialUsecase() { var hasher = new BCryptHashProvider(); var original = Guid.NewGuid().ToString(); var password = $"{Guid.NewGuid()}{Guid.NewGuid()}"; var salt = hasher.GenerateSalt(); Assert.NotNull(salt); var hashed = hasher.HashString(original, salt); Assert.NotNull(hashed); var match = hasher.Verify(original, hashed, salt); Assert.True(match); }
public void BCryptWorkFactorPerformance(int workFactor, double expectedDurationInMilliseconds) { var start = DateTimeOffset.Now; var hasher = new BCryptHashProvider(workFactor); var original = Guid.NewGuid().ToString(); var password = $"{Guid.NewGuid()}{Guid.NewGuid()}"; var hashed = hasher.HashString(original, null); Assert.NotNull(hashed); var match = hasher.Verify(original, hashed, null); Assert.True(match); Assert.True((DateTimeOffset.Now - start).TotalMilliseconds < expectedDurationInMilliseconds); }