0

I need to decompress some blob data in an android SQL database.

The programmer that developed the app/database busted his phone so can't get hold of him and this is a bit time sensitive for the company..

The data looks like:

xœÅ—ÛŽÛ6†_…Ð"¹²­“íµäÃÖM²M/Û´@¯
J¢$b%R ){7êkôÉ:¤,­|l³¤&|A‘âü3ó
I-ºARí
²´J,2ÊBg^á$¡,EYÌ.–ÖͽùY«…ÂQAЖ&*_Z®ã¼±PNh–«¶×.GÙÐÌ
ýñ¬z‚µ¸H,ËÆ¤(d…c°Òõ÷VuŒˆnQ߃—W[ ó4cK+&L¡g&­–nb¢Ÿ¶Bÿ»Õç8’bCñ`-(.39”DÐtnÞ’ô  ½1H6Qoó›”‘wäM¬Õ¼H˜oˆØ¡*çŒ V—(Î1ËHÒÉ:#¶ïK—ñٿϱr‹ûµnÿ©£Û½ñØÑ­ÇBx4ù6ûѳäôê¥yrn$øö(œM O3sfê™8ŸFÇìÆ/Ùq¿­®ÿL«çèvD+Àú‘¢O4œ²÷5|ÎÉ…zI¹@;]N?qžAŒ×qÌk¦Ð£\TŸ}´Pi“˜2ô;lìôn‚±3öè·_×ì^'ðÂØÕûàufµÉ œ Ì

I cant figure out what compression this is.. Running a standard decompress throws exceptions that this is not compressed but it is...

If anyone could point my into the right direction, I would really appreciate it.

CL.
  • 173,858
  • 17
  • 217
  • 259
Migz
  • 163
  • 1
  • 13
  • Yeah tell me about it .. Hoping someone here might recognize it a bit and lead me on the right path .. – Migz Feb 22 '16 at 09:03
  • @HrundiV.Bakshi The `x` at the beginning shows that this is likely to be [zlib-compressed](http://stackoverflow.com/questions/9050260/what-does-a-zlib-header-look-like). – CL. Feb 22 '16 at 09:05
  • What do you mean with "standard decompress"? – CL. Feb 22 '16 at 09:06
  • using (DeflateStream decompressionStream = new DeflateStream(stream , CompressionMode.Decompress)) – Migz Feb 22 '16 at 09:10

1 Answers1

1

I found my answer. The C# Lib for zLib needs the first 2 Bytes stripped off before deflating the data.

Here is the code to deflate zlib compressed data straight out of a database

// The byte[] byteData just for the lenth of the data, Mod the Mem Stream line if you want it more tidy..

byte[] byteData = cursor.GetBlob (cursor.GetColumnIndexOrThrow("Data")); 

MemoryStream stream = new MemoryStream(cursor.GetBlob (cursor.GetColumnIndexOrThrow("Data")),2,byteData.Length -2);

string BuildDataFromCompression = "";
using (DeflateStream decompressionStream = new DeflateStream(stream   , CompressionMode.Decompress))
using (var streamReader = new StreamReader(decompressionStream))
{
    BuildDataFromCompression = streamReader.ReadToEnd();
}       
Migz
  • 163
  • 1
  • 13