Example #1
0
        public async Task CheckHashFailTest()
        {
            // Arrange
            var handler = new ArgonHash(degrees, argonIterations, memorySpace, saltLength, hashLength);

            // Act
            bool matches = await handler.CheckHashAsync(sample, failHash);

            // Assert
            Assert.IsFalse(matches);
        }
Example #2
0
        public async Task GetAndCheckHashTest()
        {
            // Arrange
            var handler = new ArgonHash(degrees, argonIterations, memorySpace, saltLength, hashLength);

            // Act
            string hash = await handler.GetHashAsync(sample);

            bool matches = await handler.CheckHashAsync(sample, hash);

            // Assert
            Assert.IsTrue(matches);
        }
Example #3
0
        public async Task CheckHashFailStreamTest()
        {
            // Arrange
            var handler = new ArgonHash(degrees, argonIterations, memorySpace, saltLength, hashLength);

            using var stream = new MemoryStream(Encoding.UTF8.GetBytes(sample));

            // Act
            bool matches = await handler.CheckHashAsync(stream, failHash);

            // Assert
            Assert.IsFalse(matches);
        }
Example #4
0
        public async Task GetAndCheckHashStreamTest()
        {
            // Arrange
            var handler = new ArgonHash(degrees, argonIterations, memorySpace, saltLength, hashLength);

            using var stream = new MemoryStream(Encoding.UTF8.GetBytes(sample));

            // Act
            string hash = await handler.GetHashAsync(stream);

            stream.Position = 0;
            bool matches = await handler.CheckHashAsync(stream, hash);

            // Assert
            Assert.IsTrue(matches);
        }