Example #1
0
        public static byte[] Compress(byte[] data)
        {
            int length1 = data.Length;
            int length2 = data.Length;

            byte[] dest = new byte[data.Length];
            if (ZLib.compress(dest, ref length2, data, data.Length) != ZLib.ZLibError.Z_OK)
            {
                return((byte[])null);
            }
            byte[] numArray = new byte[length2 + 4];
            Array.Copy((Array)dest, 0, (Array)numArray, 4, length2);
            numArray[0] = (byte)(length1 & (int)byte.MaxValue);
            numArray[1] = (byte)(length1 >> 8 & (int)byte.MaxValue);
            numArray[2] = (byte)(length1 >> 16 & (int)byte.MaxValue);
            numArray[3] = (byte)(length1 >> 24 & (int)byte.MaxValue);
            return(numArray);
        }
Example #2
0
        public static byte[] Compress(byte[] data)
        {
            int length = (int)data.Length;
            int num    = (int)data.Length;

            byte[] numArray = new byte[(int)data.Length];
            if (ZLib.compress(numArray, ref num, data, (int)data.Length) != ZLib.ZLibError.Z_OK)
            {
                return(null);
            }
            byte[] numArray1 = new byte[num + 4];
            Array.Copy(numArray, 0, numArray1, 4, num);
            numArray1[0] = (byte)(length & 255);
            numArray1[1] = (byte)(length >> 8 & 255);
            numArray1[2] = (byte)(length >> 16 & 255);
            numArray1[3] = (byte)(length >> 24 & 255);
            return(numArray1);
        }