Esempio n. 1
0
        /// <summary>
        /// Decompresses the given payload data.
        /// </summary>
        /// <param name="compressedPayload">The compressed payload data.</param>
        /// <returns>The decompressed payload data.</returns>
        public static byte[] Decompress(byte[] compressedPayload)
        {
            byte[] innerHeader    = Sequence.ReadBlock(compressedPayload, 0, 11);
            byte[] compressedData = Sequence.ReadBlock(compressedPayload, 11, compressedPayload.Length - 11 - 3);

            byte[] decompressedData = ZLib.DecompressData(compressedData);

            return(Sequence.Concat(innerHeader, decompressedData));
        }
Esempio n. 2
0
        /// <summary>
        /// Compresses the given payload data.
        /// </summary>
        /// <param name="payload">The uncompressed payload data.</param>
        /// <returns>The compressed payload data.</returns>
        public static byte[] Compress(byte[] payload)
        {
            byte[] innerHeader      = Sequence.ReadBlock(payload, 0, 11);
            byte[] uncompressedData = Sequence.ReadBlock(payload, 11, payload.Length - 11);
            var    end = new byte[3];

            byte[] compressedData = ZLib.CompressData(uncompressedData);

            return(Sequence.Concat(innerHeader, compressedData, end));
        }