public void ComputeHash_given_null_or_whitespace_password_throws_ArgumentException(string password)
        {
            // arrange
            CryptoService cryptoService = new CryptoService();

            // assert
            Assert.Throws<ArgumentException>(() => cryptoService.ComputeHash("salt", password));
        }
        public void ComputeHash_given_salt_and_password_returns_hash()
        {
            // arrange
            CryptoService cryptoService = new CryptoService();

            // act
            string hash = cryptoService.ComputeHash("R9WRwHWu+SXABMLfG+2i3rAb6BmsbDf0rFnm0XkSyzk=", "password");

            // assert
            Assert.That(hash, Is.Not.Null.Or.Empty);
        }
        public void ComputeHash_given_same_salt_with_different_passwords_returns_different_hashes()
        {
            // arrange
            CryptoService cryptoService = new CryptoService();

            // act
            string hash1 = cryptoService.ComputeHash("R9WRwHWu+SXABMLfG+2i3rAb6BmsbDf0rFnm0XkSyzk=", "password1");
            string hash2 = cryptoService.ComputeHash("R9WRwHWu+SXABMLfG+2i3rAb6BmsbDf0rFnm0XkSyzk=", "password2");

            // assert
            Assert.That(hash1, Is.Not.Null.Or.Empty);
            Assert.That(hash2, Is.Not.Null.Or.Empty);
            Assert.That(hash1 != hash2);
        }
        public void Generator()
        {
            CryptoService cryptoService = new CryptoService();

            const string password = "******";

            string salt = cryptoService.GenerateSalt(password);
            string hash = cryptoService.ComputeHash(salt, password);

            Console.WriteLine("{0} {1}", salt, hash);
        }
        public void ComputeHash_called_repeatedly_with_same_salt_and_password_returns_same_hash()
        {
            // arrange
            CryptoService cryptoService = new CryptoService();

            // act
            string hash1 = cryptoService.ComputeHash("R9WRwHWu+SXABMLfG+2i3rAb6BmsbDf0rFnm0XkSyzk=", "password");
            string hash2 = cryptoService.ComputeHash("R9WRwHWu+SXABMLfG+2i3rAb6BmsbDf0rFnm0XkSyzk=", "password");

            // assert
            Assert.That(hash1, Is.Not.Null.Or.Empty);
            Assert.That(hash2, Is.Not.Null.Or.Empty);
            Assert.That(hash1 == hash2);
        }
        public void ComputeHash_given_different_salts_with_same_password_returns_different_hashes()
        {
            // arrange
            CryptoService cryptoService = new CryptoService();

            // act
            string hash1 = cryptoService.ComputeHash("R9WRwHWu+SXABMLfG+2i3rAb6BmsbDf0rFnm0XkSyzk=", "password");
            string hash2 = cryptoService.ComputeHash("lqeCOZp4gkbl5AjS80FNbYjr+HU9GGS2wtKo9HRQm+I=", "password");

            // assert
            Assert.That(hash1, Is.Not.Null.Or.Empty);
            Assert.That(hash2, Is.Not.Null.Or.Empty);
            Assert.That(hash1 != hash2);
        }