I am trying to compress a string in my Android app (Java) and then decompress it on the server with Python. I tried using the Inflater class, but then I get an "error: Error -3 while decompressing data: incorrect header check" on the python side. On the python side, I'm using zlib to decompress:
data_string = zlib.decompress(compressed_string)
On the Android side, we are using Deflater to compress:
String stringData = commentData == null ? sleepData.toString() : sleepData.toString() + commentData.toString();
byte[] bytes = stringData.getBytes("UTF-8");
int length = bytes.length;
Deflater deflater = new Deflater();
deflater.setInput(bytes);
deflater.finish();
byte[] compressedBytes = new byte[length];
deflater.deflate(compressedBytes);
deflater.end();
How can I decompress in python the string that the app is sending?
Thanks!
EDITS: This is what we are sending from Android and are feeding into the decompress command: (the dots represent just more of the same - there are a lot of zeros and then some "0b's" in the end: "78efbfbdefbfbdefbfbdefbfbd6e1b2....efbfbd190000000.....0000000000000b0b0b0b0b0b0b0b0b0b0b
Things we have tried:
-- data_string = zlib.decompress(decrypted,-zlib.MAX_WBITS), which gives a new error: "Error -3 while decompressing data: invalid stored block lengths"
-- data_string = zlib.decompressobj(decrypted,15+32) and data_string = zlib.decompress(compressed_string, 16+zlib.MAX_WBITS) which both give the initial error "invalid header check".