コード例 #1
0
        public async Task CheckFileHashAsyncTest()
        {
            // Arrange
            var handler = new ScryptHash(scryptIterations, blockSize, threadCount);

            // Act
            bool matches = await handler.CheckFileHashAsync(filename, fileHash);

            // Assert
            Assert.IsTrue(matches);
        }
コード例 #2
0
        public async Task CheckHashFailTest()
        {
            // Arrange
            var handler = new ScryptHash(scryptIterations, blockSize, threadCount);

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

            // Assert
            Assert.IsFalse(matches);
        }
コード例 #3
0
        public async Task GetHashAsyncTest()
        {
            // Arrange
            var handler = new ScryptHash(scryptIterations, blockSize, threadCount);

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

            // Assert
            Assert.IsTrue(hash.Length > 0);
        }
コード例 #4
0
        public async Task CheckHashFailStreamTest()
        {
            // Arrange
            var handler = new ScryptHash(scryptIterations, blockSize, threadCount);

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

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

            // Assert
            Assert.IsFalse(matches);
        }
コード例 #5
0
        public async Task GetHashAsyncStreamTest()
        {
            // Arrange
            var handler = new ScryptHash(scryptIterations, blockSize, threadCount);

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

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

            // Assert
            Assert.IsTrue(hash.Length > 0);
        }
コード例 #6
0
        public async Task GetAndCheckHashTest()
        {
            // Arrange
            var handler = new ScryptHash(scryptIterations, blockSize, threadCount);

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

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

            // Assert
            Assert.IsTrue(matches);
        }
コード例 #7
0
        public async Task GetAndCheckHashStreamTest()
        {
            // Arrange
            var handler = new ScryptHash(scryptIterations, blockSize, threadCount);

            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);
        }