コード例 #1
0
ファイル: ContentHasher.cs プロジェクト: shivanshu3/BuildXL
                public GuardedHashAlgorithm(HashingStreamImpl ownerStream, long streamLength, ContentHasher <T> hasher)
                {
                    _ownerStream = ownerStream;
                    _hasherToken = hasher.CreateToken();

                    var hashAlgorithm = _hasherToken.Hasher;

                    if (streamLength >= 0 && hashAlgorithm is IHashAlgorithmInputLength sizeHint)
                    {
                        sizeHint.SetInputLength(streamLength);
                    }

                    if (!hashAlgorithm.CanTransformMultipleBlocks)
                    {
                        throw new NotImplementedException();
                    }

                    if (hashAlgorithm.InputBlockSize != 1)
                    {
                        throw new NotImplementedException();
                    }

                    if (hashAlgorithm.OutputBlockSize != 1)
                    {
                        throw new NotImplementedException();
                    }
                }
コード例 #2
0
        private HasherToken CreateToken(long expectedLength)
        {
            var poolHandle = _algorithmsPool.Get();
            var result     = new HasherToken(poolHandle);

            if (result.Hasher is IHashAlgorithmInputLength sizeHint)
            {
                sizeHint.SetInputLength(expectedLength);
            }

            return(result);
        }
コード例 #3
0
            public HashingStreamImpl(Stream stream, ContentHasher <T> hasher, CryptoStreamMode mode, bool useParallelHashing, long parallelHashingFileSizeBoundary)
            {
                Contract.Requires(stream != null);
                Contract.Requires(hasher != null);
                Contract.Requires(useParallelHashing || parallelHashingFileSizeBoundary == -1);

                _baseStream         = stream;
                _hasher             = hasher;
                _streamMode         = mode;
                _useParallelHashing = useParallelHashing;
                _parallelHashingFileSizeBoundary = parallelHashingFileSizeBoundary;

                if (_useParallelHashing)
                {
                    _hashingBufferBlock = new ActionBlock <Pool <Buffer> .PoolHandle>(
                        HashSegmentAsync,
                        new ExecutionDataflowBlockOptions()
                    {
                        MaxDegreeOfParallelism = 1
                    });
                }

                _hasherHandle  = hasher.CreateToken();
                _hashAlgorithm = _hasherHandle.Hasher;

                if (!_hashAlgorithm.CanTransformMultipleBlocks)
                {
                    throw new NotImplementedException();
                }

                if (_hashAlgorithm.InputBlockSize != 1)
                {
                    throw new NotImplementedException();
                }

                if (_hashAlgorithm.OutputBlockSize != 1)
                {
                    throw new NotImplementedException();
                }
            }
コード例 #4
0
ファイル: ContentHasher.cs プロジェクト: sahilmgandhi/BuildXL
                public GuardedHashAlgorithm(HashingStreamImpl ownerStream, ContentHasher <T> hasher)
                {
                    _ownerStream = ownerStream;
                    _hasherToken = hasher.CreateToken();

                    var hashAlgorithm = _hasherToken.Hasher;

                    if (!hashAlgorithm.CanTransformMultipleBlocks)
                    {
                        throw new NotImplementedException();
                    }

                    if (hashAlgorithm.InputBlockSize != 1)
                    {
                        throw new NotImplementedException();
                    }

                    if (hashAlgorithm.OutputBlockSize != 1)
                    {
                        throw new NotImplementedException();
                    }
                }