Exemplo n.º 1
0
 /// <summary>
 /// Creates a SaltedHasher, configuring it to use the specified hashing provider, salt position and salt length, and password generator
 /// </summary>
 /// <param name="provider">Hash algorithm to use by default</param>
 /// <param name="saltLength">Length for the salt</param>
 /// <param name="saltPosition">Position for the salt</param>
 /// <param name="passwordGenerator">Password generator for generating the salts</param>
 SaltedHasher(HashProvider provider, int saltLength, SaltPosition saltPosition, PasswordGenerator passwordGenerator)
 {
     Provider = provider;
     SaltPosition = saltPosition;
     SaltLength = saltLength;
     PasswordGenerator = passwordGenerator;
 }
        public void Length_of_generated_password_should_match_specified_length()
        {
            const int length = 15;

            var generator = new PasswordGenerator();

            var password = generator.Generate(length);

            Assert.AreEqual(length, password.Length);
        }
        public void Length_of_generated_password_should_match_configured_default()
        {
            const int length = 15;

            var generator = new PasswordGenerator {MinimumPasswordLength = length, MaximumPasswordLength = length};

            var password = generator.Generate();

            Assert.AreEqual(length, password.Length);
        }