Jump to content

Compresion problem!

- - - - -

  • Please log in to reply
No replies to this topic

#1
Peacemaker

Peacemaker

    Newbie

  • Members
  • PipPip
  • 11 posts
So i have situation where i need to compress output from php and i don that by using this:

echo base64_encode(gzcompress($xml, 9))
I also tried without the compression level or with a another number, but it's not working.

And here is the code i am using for decompression(C#):

public static string Decompress(string compressed)

        {

            byte[] compressedBytes = Convert.FromBase64String(compressed);

            using (var mem = new MemoryStream())

            {

                mem.Write(new byte[] { 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 8);

                mem.Write(compressedBytes, 0, compressedBytes.Length);


                mem.Position = 0;


                using (var gzip = new GZipStream(mem, CompressionMode.Decompress))

                using (var reader = new StreamReader(gzip))

                {

                    return reader.ReadToEnd();

                }

            }

        }
Can you help me, how i suppose to get the same result after decompression?
spammy sig deleted by management




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users