public void TestBCryptConfigurationConstructor512() { BCryptConfiguration configuration = new BCryptConfiguration(KeyDerivationPrf.HMACSHA512, 2); Assert.AreEqual(configuration.Prf, KeyDerivationPrf.HMACSHA512); Assert.AreEqual(configuration.IterationCount, 2); }
public void TestBCryptConfigurationDefault() { BCryptConfiguration configuration = new BCryptConfiguration(); Assert.AreEqual(configuration.Prf, KeyDerivationPrf.HMACSHA512); Assert.AreEqual(configuration.IterationCount, 10000); }
public void TestBCryptConstructorReturnValueWithHMACSHA256() { string password = "******"; BCryptConfiguration configuration = new BCryptConfiguration(KeyDerivationPrf.HMACSHA256); BCrypt bCrypt = new BCrypt(configuration); BCryptValue bCryptValue = bCrypt.Hash(password); Assert.IsTrue(bCrypt.Valid(password, bCryptValue)); }
public void TestBCryptConstructorReturnValue() { string password = "******"; BCryptConfiguration configuration = new BCryptConfiguration(); BCrypt bCrypt = new BCrypt(configuration); BCryptValue bCryptValue = bCrypt.Hash(password); Assert.IsTrue(bCrypt.Valid(password, bCryptValue)); }
public void TestBCryptConfigurationConstructor512SaltAndHashed() { BCryptConfiguration configuration = new BCryptConfiguration(KeyDerivationPrf.HMACSHA512, 2, 1, 1); Assert.AreEqual(configuration.Prf, KeyDerivationPrf.HMACSHA512); Assert.AreEqual(configuration.IterationCount, 2); Assert.AreEqual(configuration.SaltBytesLength, 1); Assert.AreEqual(configuration.NumBytesRequestedLength, 1); }
public void TestBCryptConstructorReturnValueWithHMACSHA512AndInterationCountDescribeValue() { string password = "******"; BCryptConfiguration configuration = new BCryptConfiguration(KeyDerivationPrf.HMACSHA512, 2000); BCrypt bCrypt = new BCrypt(configuration); BCryptValue bCryptValue = bCrypt.Hash(password); Assert.IsTrue(bCrypt.Valid(password, bCryptValue.Salt, bCryptValue.Hashed)); }
public void TestBCryptConstructorReturnValueWithHMACSHA512AndInterationCountDescribeValueSaltAndHashedLength() { const int length = 75; string password = "******"; BCryptConfiguration configuration = new BCryptConfiguration(KeyDerivationPrf.HMACSHA512, 2000, length, length); BCrypt bCrypt = new BCrypt(configuration); BCryptValue bCryptValue = bCrypt.Hash(password); Assert.IsTrue(bCrypt.Valid(password, bCryptValue.Salt, bCryptValue.Hashed)); Assert.AreEqual(2000, configuration.IterationCount); Assert.AreEqual(length, configuration.SaltBytesLength); Assert.AreEqual(length, configuration.NumBytesRequestedLength); Assert.AreEqual(bCryptValue.Salt.Length, 100); Assert.AreEqual(bCryptValue.Hashed.Length, 100); }
/// <summary> /// static class GeneratePasswordExtensions /// </summary> /// <param name="services">IServiceCollection</param> /// <param name="configuration">BCryptConfiguration</param> /// <returns></returns> public static IServiceCollection AddGeneratePassword( this IServiceCollection services, Action <BCryptConfiguration> configuration = null) { BCryptConfiguration config = new BCryptConfiguration(); if (configuration != null) { configuration?.Invoke(config); } services.AddScoped(_ => config); services.AddScoped <BCrypt>(); return(services); }
public void TestBCryptConfigurationInstance() { BCryptConfiguration configuration = new BCryptConfiguration(); Assert.IsInstanceOf <BCryptConfiguration>(configuration); }