3

I am trying to decompress a byte array.

byte[] bloc = { 120, 156, 211, 97, 144, 76, 247, 142, 98, 228, 98, 0, 2, 70, 101, 6, 166, 8, 16, 131, 133, 131, 145, 129, 209, 134, 129, 133, 1, 44, 12, 4, 202, 118, 12, 0, 70, 22, 2, 148 };

As you can see the header is 120 165 (78 9c in hex) witch is the zlib default Compression algorithme. I used the ComponentAce.Compression.ZipForge from the zlib site. I couldn't find samples on how to unzip streams(not files).

Codor
  • 17,447
  • 9
  • 29
  • 56
user3468143
  • 31
  • 1
  • 1
  • 3
  • 1
    Why not just use the built-in .NET streams like DeflateStream etc? – Sami Kuhmonen Dec 20 '16 at 09:42
  • Have you seen the first answer here : http://www.componentace.com/help/zf_guide/zipforgefaq.htm - try creating a memory stream & passing to the OpenArchive method – PaulF Dec 20 '16 at 09:44

1 Answers1

3

Use SharpZipLib. It includes a full interface to zlib, and will decompress zlib streams as well as other compressed data formats such as gzip, zip, bzip2, and raw deflate.

You should avoid the .NET components provided by Microsoft as they are buggy (in particular in not properly detecting invalid input) and Microsoft has stated that they will not fix it.

Community
  • 1
  • 1
Mark Adler
  • 101,978
  • 13
  • 118
  • 158