SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Add Adler32 checksum to Zip file

Last post 08-21-2008 9:26 PM by JohnReilly. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-20-2008 9:31 PM

    • lokoz
    • Not Ranked
    • Joined on 08-20-2008
    • Posts 2

    Add Adler32 checksum to Zip file

     Hi all,

     

    I'm new to SharpZipLib and I have a problem I've been struggling with for some time now. I need to create Zip files with ZipLib that also have the Adler32 checksum embedded in them, in much the same way as the CRC32is embedded. I found some examples where people embed CRC32... something like this:

    ...

    Crc32 crc = new Crc32();

    crc.reset();

    crc.update(buffer);

    zipEntry.Crc = crc.value;

    ...

    Now I have figured out how to create an instance of an Adler class and compute the Adler checksum, but I can't manage to incorporate the checksume in the resulting ZIp file. I searched fore something like: zipEntry.Adler = adler.value; but no luck. Could someone please help me out? I would appreciate it. 

    Cheers

    Filed under: ,
  • 08-20-2008 9:57 PM In reply to

    Re: Add Adler32 checksum to Zip file

    Hi,

    Crc are directly supported as they are required by the format to create valid archives.  The best place to add an adler checksum is in the extra data which is extendable as long as both compressor and decompressor understand whats going on.  Extra data uses an identifier for each item of data so you should pick one thats not reserved for use by others.  you will need to grab the zip app note and consult it to work out a good value.  Its in the wiki or you could google also I think.

    There are no samples for this as its not all that usual but there is a zip extra data class that can be used to handle this kind of thing.  You should grab the source code and have a look into how it all fits together.

    If you get stuck come back and I'll give you are few deeper pointers.  It may take a while as I have higher priority stuff going on but all you need to be is patient.  Of course another eager developer may take up the case as well :-).

     

    BTW why do you need this information and must it be stored?  You could also calculate this on extraction or viewing if needed which may take a moment or two but will work for arbitrary files not just specially formatted ones.

     hth, -jr-

     

     

     

  • 08-20-2008 10:13 PM In reply to

    • lokoz
    • Not Ranked
    • Joined on 08-20-2008
    • Posts 2

    Re: Add Adler32 checksum to Zip file

     Hi,

     Thanks for you response. Yeah, I was pretty sure myself that the Adler32 checksum would need to go somewhere in the ExtraData section. I will look into it and hopefully get to the end of it.

     As for why do I need this: I need to create zip files in .NET which can be then unzipped in ActionScript3 using the fzip library (http://codeazur.com.br/lab/fzip/). The problem is that: "In order to be able to decompress compressed files
                in a ZIP archive, FZip requires the presence of an Adler32
                checksum in addition to the standard CRC32 checksums contained
                in ZIP archives."

     I really don't know why this is required. I also tought about changing the FZip library code so that it doesn't require the Adler32, but I can't seem to find a complex enough documentation about the Zip file format.

    Anyway, thanks for the info. Should be a good starting point.

  • 08-21-2008 9:26 PM In reply to

    Re: Add Adler32 checksum to Zip file

    In that case you should look at the fzip documentation to see what is required to be compatible.

    hth, -jr-

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.