C#, Decompress a stream using zlib

六月ゝ 毕业季﹏ 提交于 2019-12-23 02:32:19

问题


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).


回答1:


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.



来源:https://stackoverflow.com/questions/41238898/c-decompress-a-stream-using-zlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!