DroidForums.net is the original Verizon Android Forum! Registered Users do not see these ads. Please Register - It's Free!
Results 1 to 1 of 1

Thread: Decompress a GZIP "string" compressed in .NET

  1. Droid Newbie
    AndPig's Avatar
    Member #
    Join Date
    Sep 2012
    Galaxy S3

    Question Decompress a GZIP "string" compressed in .NET

    Hallo - I'm new here and also fairly new to Android development, hopefully someone can help me with this issue.

    I've got an issue trying to decompress something that was compressed in VB.NET using Gzip.

    In .NET the following occurs to an XML file:

    - The file is compressed using Gzip
    - The result is encrypted using Triple3DES
    - The result is saved to a file

    In Android, I've got the 3DES decryption working fine, which when I open a file where I only encrypted in .NET, returns the XML that was originally encrypted.

    The problem is trying to get the decompress function working also. I think the issue relates to the compressed data being binary and not a string, but only a hunch.

    This is my decrypt function - I use fileToByteArray to convert the file on the SD card to pass in as 'message':

    public static String decrypt(byte[] message) throws Exception {
        	final byte[] keyBytes = "1232223423513131".getBytes();
            final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
            final IvParameterSpec iv = new IvParameterSpec("12345678".getBytes());
            final Cipher decipher = Cipher.getInstance("DESede/CBC/PKCS7Padding");
            decipher.init(Cipher.DECRYPT_MODE, key, iv);
            final byte[] plainText = decipher.doFinal(message);
            return new String(plainText);
    The above works fine when I open a file that was only encrypted in .NET. But if I try to decompress the resultant string with the below, I get an "Unknown format (magic number 8)" error. Note, I've tried about 10 different decompress functions I've found online, all do the same:

    public static String decompress(String gzipString) throws IOException {
    	    int size = 0;
    	    byte[] gzipBuff = gzipString.getBytes();
    	    ByteArrayInputStream memstream = new ByteArrayInputStream(gzipBuff, 4,
    	            gzipBuff.length - 4);
    	    GZIPInputStream gzin = new GZIPInputStream(memstream);
    	    final int buffSize = 8192;
    	    byte[] tempBuffer = new byte[buffSize];
    	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    	    while ((size = gzin.read(tempBuffer, 0, buffSize)) != -1) {
    	        baos.write(tempBuffer, 0, size);
    	    byte[] buffer = baos.toByteArray();
    	    return new String(buffer, "UTF-8");
    The gzipString parameter value passed in to the decompress function looks like binary would as a string.. it contains lots of odd characters that won't paste into here. Not sure if that helps!

    Can anyone suggest what might be wrong, or a good path for investigating this further?

    Any help appreciated.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Similar Threads

  1. Replies: 2
    Last Post: 08-23-2012, 07:05 AM
  2. Replies: 2
    Last Post: 08-01-2012, 11:49 AM
  3. Replies: 16
    Last Post: 04-08-2012, 09:28 AM
  4. Viewing "canned responses" or "email templates" in gmail on the Droid 2
    By backcountrywarehouse in forum Motorola Droid 2
    Replies: 0
    Last Post: 01-25-2011, 05:39 PM
  5. Replies: 4
    Last Post: 12-17-2010, 06:44 AM

Search tags for this page

.net gzip a string
.net gzip string
android and vb string compression
android decode gzip
decompress gzip string vb.net

gzip string online


vb.net compress string

vb.net compress xml string
vb.net gzip code
vb.net gzipstream decompress unknown buffer size
Click on a term to search our site for related topics.

Tags for this Thread

Find us on Google+