Esempio n. 1
0
            public void ReturnsRandomSaltString()
            {
                // Arrange
                var hasher = new HashService();

                // Act
                var salt1 = hasher.GenerateSalt();
                var salt2 = hasher.GenerateSalt();

                // Assert
                Assert.NotEmpty(salt1);
                Assert.NotEmpty(salt2);
                Assert.NotEqual(salt1, salt2);
            }
Esempio n. 2
0
            public void GeneratesHMACSHA256HashOfInputsAsBase64()
            {
                // Pre-calculated
                const string expected = "syG5MRKK0ixBtoIFGOLvu3gmhwC0TAJ/0wWQ6V1iAHQ=";

                // Arrange
                var hasher = new HashService();
                var salt = Convert.ToBase64String(new byte[] { 1, 2, 3, 4, 5 });
                var value = "password";

                // Act
                var actual = hasher.GenerateHash(value, salt);

                // Assert
                Assert.Equal(expected, actual);
            }
Esempio n. 3
0
 public AuthenticationService(IDataRepository data, HashService hasher, HttpContextBase context)
 {
     Data = data;
     Hasher = hasher;
     Context = context;
 }