Пример #1
0
        public void ComputeHash_WithSalt_ComputesSameHash()
        {
            // Arrange
            var secret = "my super secret password";
            var salt   = SHAHash.GenerateSalt(128);

            // Act
            var result1 = SHAHash.ComputeHash(secret, salt);
            var result2 = SHAHash.ComputeHash(secret, salt);

            // Assert
            Assert.Equal(result1.HashedData, result2.HashedData);
            Assert.Equal(salt, result2.Salt);
        }
Пример #2
0
        public void ComputeHash_WithSalt_ComputesDifferentHashForDifferentValues()
        {
            // Arrange
            var secret1 = "my super secret password";
            var secret2 = "my super secret password, part deux";

            var salt = SHAHash.GenerateSalt(128);

            // Act
            var result1 = SHAHash.ComputeHash(secret1, salt);
            var result2 = SHAHash.ComputeHash(secret2, salt);

            // Assert
            Assert.NotEqual(result1.HashedData, result2.HashedData);
            Assert.Equal(salt, result1.Salt);
            Assert.Equal(salt, result2.Salt);
        }