Example #1
0
        public void FactoryMethodShouldThrowException()
        {
            const string plaintext  = "F0o!";
            const int    iterations = 1;

            Assert.Throws <ArgumentException>(() => PasswordHash.From(plaintext, iterations, 7));
        }
Example #2
0
        public void FactoryMethodShouldThrowException()
        {
            const string plaintext  = "F0o!";
            const int    iterations = 0;
            const int    bits       = 256;

            Assert.Throws <ArgumentOutOfRangeException>(() => PasswordHash.From(plaintext, iterations, bits / 8));
        }
Example #3
0
        public void FactoryMethodShouldThrowException()
        {
            const string plaintext  = null;
            const int    iterations = 1000;
            const int    bits       = 256;

            Assert.Throws <ArgumentNullException>(() => PasswordHash.From(plaintext, iterations, bits / 8));
        }
Example #4
0
        public void ItShouldMatch()
        {
            const string plaintext  = "Fo0!";
            const int    iterations = 1000;
            const int    bits       = 256;

            var hash = PasswordHash.From(plaintext, iterations, bits / 8);

            Assert.True(hash.IsMatch(plaintext));
        }
Example #5
0
        public void ItShouldFailToMatch()
        {
            const string plaintext          = "Fo0!";
            const string incorrectPlaintext = "b4r1";
            const int    iterations         = 1000;
            const int    bits = 256;

            var hash = PasswordHash.From(plaintext, iterations, bits / 8);

            Assert.False(hash.IsMatch(incorrectPlaintext));
        }
Example #6
0
 public PasswordHash StaticFactory() => PasswordHash.From("Testing!234", Iterations, HashSize / 8);