S
S
semax952016-09-04 14:31:13
Android
semax95, 2016-09-04 14:31:13

How to decompress gzip android?

Hello.
For the project, I need to unpack the string packed by the php function

<?php
echo base64_encode(aes(gzdeflate("123456")));

I know about transparent decompression of gzip in OkHttp, but unfortunately it doesn't work because the data is encrypted with aes.
in the end, the program works like this:
we request data from the server, remove aes and only then unpack gzip.
it doesn't make sense to pack with gzip aes, the original data weighs ~ 5 mb, if gzip walks through unencrypted data, they weigh 200 kb, if gzip walks through aes, then 3 mb

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
semax95, 2016-09-04
@semax95

android code

public static byte[] decompress(byte[] data) throws IOException, DataFormatException {
        Inflater inflater = new Inflater(true);
        inflater.setInput(data);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
        byte[] buffer = new byte[1024];
        while (!inflater.finished()) {
            int count = inflater.inflate(buffer);
            outputStream.write(buffer, 0, count);
        }
        outputStream.close();
        byte[] output = outputStream.toByteArray();
     //   LOG.debug("Original: " + data.length);
      //  LOG.debug("Compressed: " + output.length);
        return output;
    }

mistake
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: java.util.zip.DataFormatException: invalid stored block lengths
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at java.util.zip.Inflater.inflateImpl(Native Method)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at java.util.zip.Inflater.inflate(Inflater.java:237)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at java.util.zip.Inflater.inflate(Inflater.java:214)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at ru.cabi.Help.decompress(Help.java:450)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at ru.cabi.Help.getData(Help.java:420)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at ru.cabi.UpdateProc.updateTimetable(UpdateProc.java:95)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at ru.cabi.SelectGActivity$TaskUpdate.doInBackground(SelectGActivity.java:402)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at ru.cabi.SelectGActivity$TaskUpdate.doInBackground(SelectGActivity.java:391)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err:     at java.lang.Thread.run(Thread.java:818)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question