// Verify password method
 public static bool Verify(string password, string passwordHash)
 {
     string[] passwordHashes = passwordHash.Split(':');
     if (passwordHashes.Length == 2)
     {
         var saltedPasswordHash = new SaltedPasswordHash(passwordHashes[0], passwordHashes[1]);
         return(saltedPasswordHash.Verify(password));
     }
     return(false);
 }
 // Password verify
 public static bool Verify(string password, string passwordHash)
 {
     string[] hashSalted = passwordHash.Split(':');
     if (hashSalted.Length == 2)
     {
         var saltedPaswordHash = new SaltedPasswordHash(hashSalted[0], hashSalted[1]);
         return(saltedPaswordHash.Verify(password));
     }
     return(false);
 }
        public void CanVerifyClearTextPasswordAgainstHashedAndSaltedPassword()
        {
            // Arrange
            var clearTextPassword    = "******";
            var originalPasswordHash = new SaltedPasswordHash(clearTextPassword);
            var retrivedPasswordHash = new SaltedPasswordHash(originalPasswordHash.Hash, originalPasswordHash.Salt);

            // Act
            bool valid = retrivedPasswordHash.Verify(clearTextPassword);

            // Assert
            valid.Should().Be.True();
        }
        public void CanVerifyClearTextPasswordAgainstHashedAndSaltedPassword()
        {
            // Arrange
            var clearTextPassword = "******";
            var originalPasswordHash = new SaltedPasswordHash(clearTextPassword);
            var retrivedPasswordHash = new SaltedPasswordHash(originalPasswordHash.Hash, originalPasswordHash.Salt);

            // Act
            bool valid = retrivedPasswordHash.Verify(clearTextPassword);

            // Assert
            valid.Should().Be.True();
        }
        public void CanVerifyTwoPasswordHashedCreatedFromClearTextPasswordsButTheyHashesAreNotEqual()
        {
            // Arrange
            var clearTextPassword = "******";
            var hash1             = new SaltedPasswordHash(clearTextPassword);
            var hash2             = new SaltedPasswordHash(clearTextPassword);

            // Act
            bool equalHashed           = hash1 == hash2;
            bool hash1VerifiesPassword = hash1.Verify(clearTextPassword);
            bool hash2VerifiesPassword = hash2.Verify(clearTextPassword);

            // Assert
            equalHashed.Should().Be.False();
            hash1VerifiesPassword.Should().Be.True();
            hash2VerifiesPassword.Should().Be.True();
        }
        public void CanVerifyTwoPasswordHashedCreatedFromClearTextPasswordsButTheyHashesAreNotEqual()
        {
            // Arrange
            var clearTextPassword = "******";
            var hash1 = new SaltedPasswordHash(clearTextPassword);
            var hash2 = new SaltedPasswordHash(clearTextPassword);

            // Act
            bool equalHashed = hash1 == hash2;
            bool hash1VerifiesPassword = hash1.Verify(clearTextPassword);
            bool hash2VerifiesPassword = hash2.Verify(clearTextPassword);

            // Assert
            equalHashed.Should().Be.False();
            hash1VerifiesPassword.Should().Be.True();
            hash2VerifiesPassword.Should().Be.True();
        }