コード例 #1
0
ファイル: OpenPgp.cs プロジェクト: n4074/SecretSplitter
        public CompressedDataOpenPgpPacket(OpenPgpPacketHeader header, Stream inputStream) : base(header, inputStream)
        {
            int compressionAlgorithmId = inputStream.ReadByte();

            CompressionAlgorithm = OpenPgpCompressionAlgorithm.GetCompressionAlgorithmById(compressionAlgorithmId);

            var decompressionStream = CompressionAlgorithm.Decompress(inputStream) as DeflateStream;

            DecompressedStream = new MemoryStream();
            decompressionStream.CopyTo(DecompressedStream);
            DecompressedStream.Position = 0;
        }
コード例 #2
0
ファイル: SaReadBlock.cs プロジェクト: zhouhufeng/Nirvana
        private void ReadCompressedBlock(Stream inputStream)
        {
            var numBytesRead = inputStream.Read(CompressedBlock, 0, Header.NumCompressedBytes);

            if (numBytesRead != Header.NumCompressedBytes)
            {
                throw new IOException($"Expected {Header.NumCompressedBytes} bytes from the block, but received only {numBytesRead} bytes.");
            }

            int numUncompressedBytes = CompressionAlgorithm.Decompress(CompressedBlock, Header.NumCompressedBytes, UncompressedBlock, UncompressedBlock.Length);

            if (numUncompressedBytes != Header.NumUncompressedBytes)
            {
                throw new CompressionException($"Expected {Header.NumUncompressedBytes} bytes after decompression, but found only {numUncompressedBytes} bytes.");
            }
        }