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

            Assert.Throws <ArgumentException>(() => PasswordHash.From(plaintext, iterations, 7));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #6
0
 public PasswordHash StaticFactory() => PasswordHash.From("Testing!234", Iterations, HashSize / 8);