public void HashServiceProducesValidSalt()
        {
            var hashService = new Rfc2898HashService();
            var salt = hashService.CreateSalt(16);

            Assert.NotNull(salt);
            Assert.Equal(16, salt.Length);
        }
        public void CanHashAndVerify()
        {
            const string testphrase = "Dr. DoLittle";
            var hashService = new Rfc2898HashService();
            var salt = hashService.CreateSalt(16);
            var testphrasebytes = Encoding.UTF8.GetBytes(testphrase);
            var hash = hashService.Hash(testphrasebytes, salt, 1, _hashParameters[1].Iterations, 64);

            Assert.NotNull(hash);
            Assert.Equal(64, hash.Length);

            var confirmation = hashService.Verify(testphrasebytes, salt, _hashParameters, hash);

            Assert.True(confirmation);
        }
        public void Run()
        {
            var instance = new Rfc2898HashService();
            var stopWatch = new Stopwatch();
            var passwordPointer = 0;
            for (var i = 0; i < 1000; i++)
            {
                var data = passwords[passwordPointer];
                stopWatch.Start();
                var salt = instance.CreateSalt(8);
                var password = instance.Hash(data, salt, 1);
                stopWatch.Stop();
                if (passwordPointer++ >= passwords.Count - 1)
                    passwordPointer = 0;
            }

            Debug.WriteLine("Total MS: {0}", stopWatch.Elapsed.TotalMilliseconds);
        }