Beispiel #1
0
        public void TooHighComplexityPasswordTest()
        {
            string password = "******";

            PasswordHashing provider = new PasswordHashing(complexity: 25);

            string hash = provider.Compute(password);
        }
Beispiel #2
0
        public void NullPasswordTest()
        {
            string password = null;

            PasswordHashing provider = new PasswordHashing();

            string hash = provider.Compute(password);
        }
Beispiel #3
0
        public void WhitespacePasswordTest()
        {
            string password = "******";

            PasswordHashing provider = new PasswordHashing();

            string hash = provider.Compute(password);
        }
Beispiel #4
0
        public void PositivePBKDF1CompareTest()
        {
            string password = "******";

            PasswordHashing provider = new PasswordHashing(algorithm: PasswordHashing.ALGORITHM.PBKDF1);

            string hash   = provider.Compute(password);
            bool   result = provider.Compare(password, hash);

            Assert.IsTrue(result);
        }
Beispiel #5
0
        public void PositiveCompareTest()
        {
            string password = "******";

            PasswordHashing provider = new PasswordHashing();

            string hash   = provider.Compute(password);
            bool   result = provider.Compare(password, hash);

            Assert.IsTrue(result);
        }
Beispiel #6
0
        public void NegativeCompareTest()
        {
            string password      = "******";
            string wrongPassword = "******";

            PasswordHashing provider = new PasswordHashing();

            string hash   = provider.Compute(password);
            bool   result = provider.Compare(wrongPassword, hash);

            Assert.IsFalse(result);
        }
Beispiel #7
0
        public void MaximumComplexityPasswordTest()
        {
            int    expected = 16777216;
            string password = "******";

            PasswordHashing provider = new PasswordHashing(complexity: 24);

            string         hash   = provider.Compute(password);
            HashedPassword hashed = (HashedPassword)hash;

            Assert.AreEqual(expected, hashed.Iterations);
        }
Beispiel #8
0
        public void ComplexityTimeIncreasePasswordTest()
        {
            string password = "******";

            PasswordHashing provider;
            string          hash;
            Stopwatch       sw;

            long first, second, third;

            provider = new PasswordHashing(complexity: 10);

            sw   = Stopwatch.StartNew();
            hash = provider.Compute(password);
            sw.Stop();

            first = sw.ElapsedTicks;

            provider = new PasswordHashing(complexity: 11);

            sw   = Stopwatch.StartNew();
            hash = provider.Compute(password);
            sw.Stop();

            second = sw.ElapsedTicks;

            provider = new PasswordHashing(complexity: 12);

            sw   = Stopwatch.StartNew();
            hash = provider.Compute(password);
            sw.Stop();

            third = sw.ElapsedTicks;

            Assert.IsTrue(first < second);
            Assert.IsTrue(second < third);
        }