henryhuang / winzipaes

Automatically exported from code.google.com/p/winzipaes
0 stars 0 forks source link

Wrong local file header signature #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I'm using this code an android : 

/**
     * @param args
     */
    public static void main(String[] args) {
        try {

            String password = "test";
            String ZIP_INIT = "hyfTmp.zip";
            String ZIP_FINAL = "hyf.zip";
            String ZIP_INIT_TMP = "hyfTmp.zip.zip";

            File hyfDir = new File("..Path to directory");
            File zipFile = new File(hyfDir, ZIP_INIT);
            ZipOutputStream outStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));

            String[] fileList = new String[] { ".. path to directory to zip" };
            File file = null;
            for (String fileOrDirectory : fileList) {
                file = new File(fileOrDirectory);
                manageFiles(file, outStream);
            }
            outStream.close();

            AesZipFileEncrypter zipEncrypter = new AesZipFileEncrypter(new File(hyfDir, ZIP_FINAL));
            zipEncrypter.zipAndEncrypt(zipFile, password);

            FileUtils.forceDelete(zipFile);
            File zipFileTemp = new File(hyfDir, ZIP_INIT_TMP);
            if (zipFileTemp.exists()) {
                FileUtils.forceDelete(zipFileTemp);
            }

            System.out.println("Finsish");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void manageFiles(File file, ZipOutputStream stream) throws Exception {
        if (file.isDirectory()) {
            for (File fileTmp : file.listFiles()) {
                manageFiles(fileTmp, stream);
            }
            // FileUtils.deleteDirectory(file);
        } else {
            stream.putNextEntry(new ZipEntry(file.getAbsolutePath()));
            InputStream input = new BufferedInputStream(new FileInputStream(file));
            IOUtils.copy(input, stream);
            try {
                IOUtils.closeQuietly(input);
            } catch (Exception e) {
                e.printStackTrace();
            }
            stream.closeEntry();
        }
    }

What is the expected output? What do you see instead?

I expected a zip crypted. I use the same code both on Ubuntu 10.4 and Windows 
XP and it works well.

What version of the product are you using? On what operating system?

I'm using version available in download part

Please provide any additional information below.

I'have filter the class used in bouncycastle. You will find the example as 
attachment.

The code works well on windows or linux but on android when it is doing 
operation zipAndEncrypt I have this stackTrace : 

07-26 12:06:12.513: ERROR/FileAPI(281): error durign saving files : 
07-26 12:06:12.513: ERROR/FileAPI(281): java.io.IOException: wrong local file 
header signature - value=00 00 00 00 
07-26 12:06:12.513: ERROR/FileAPI(281):     at 
de.idyl.crypto.zip.impl.ZipFileEntryInputStream.nextEntry(ZipFileEntryInputStrea
m.java:58)
07-26 12:06:12.513: ERROR/FileAPI(281):     at 
de.idyl.crypto.zip.AesZipFileEncrypter.add(AesZipFileEncrypter.java:64)
07-26 12:06:12.513: ERROR/FileAPI(281):     at 
de.idyl.crypto.zip.AesZipFileEncrypter.addEncrypted(AesZipFileEncrypter.java:169
)
07-26 12:06:12.513: ERROR/FileAPI(281):     at 
de.idyl.crypto.zip.AesZipFileEncrypter.zipAndEncrypt(AesZipFileEncrypter.java:15
2)
07-26 12:06:12.513: ERROR/FileAPI(281):     at 
com.officetelecom.hydeyourfriends.api.FileAPI.applyRemove(FileAPI.java:85)
07-26 12:06:12.513: ERROR/FileAPI(281):     at 
com.officetelecom.hydeyourfriends.api.HideYourFriendsAPI.applyRemove(HideYourFri
endsAPI.java:156)
07-26 12:06:12.513: ERROR/FileAPI(281):     at 
com.officetelecom.hydeyourfriends.service.HYFService$2.run(HYFService.java:108)
07-26 12:06:12.513: ERROR/FileAPI(281):     at 
java.lang.Thread.run(Thread.java:1096)

Did you have any idea ?

Original issue reported on code.google.com by jean.fra...@gmail.com on 26 Jul 2010 at 3:52

Attachments:

GoogleCodeExporter commented 9 years ago
Could you try the latest code available via SVN? I'll have to do a relase 
(download zip), but as I'm still thinking, if I should "mavenize" the project, 
did not do it.

Regards,
Olaf 

Original comment by olaf.merkert on 26 Jul 2010 at 7:21

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
With the code of trunk it seems to work.

Could you please also think to close the inputStream in add method because or 
manage the close of inputStream for add(File,...) method 

I would like to know wich encrypter do I have to use ? AesZipFileEncrypter or 
AesZipFileEncrypterNew ?

best regards

Original comment by jean.fra...@gmail.com on 27 Jul 2010 at 12:35

GoogleCodeExporter commented 9 years ago
1. AesZipFileEncrypterNew is removed now (missing "cleanup", after updating 
AesZipFileEncrypter with the "in-memory" code provided by jean-luc)
2. regarding the close(): I've added the close statements, thanks for the input

Original comment by olaf.merkert on 28 Jul 2010 at 8:31

GoogleCodeExporter commented 9 years ago
Hello Olaf,

I am using latest version of code (2010-11-28) and when I try to encrypt ZIP 
file I get this error message:

"wrong local file header signature - value=00 00 00 00"

I have tried with AesZipFileEncrypter.zipAndEncryptAll(new 
File(destinationFile), new File(destinationFile + ".test"), pwd);

AesZipFileEncrypter encrypt = new AesZipFileEncrypter(destinationFile);
encrypt.addAll(new File(sourceFile), pwd);

But I always get that error message. I guess that there is something wrong with 
my ZIP files that I create as normal ZIP files. How should I create ZIP file to 
be able to encrypt it?

Thank you in advance.

Original comment by amirs...@gmail.com on 6 Jan 2011 at 10:05

GoogleCodeExporter commented 9 years ago
Hello,

can you provide (attach) the (un-encrypted) zip file you created? Did you use 
java.util.zip to create the file?

Regards,
Olaf

Original comment by olaf.merkert on 7 Jan 2011 at 11:44

GoogleCodeExporter commented 9 years ago
Hello,

Yes, I have used Java.utility.zip to create ZIP file. Is there other way and if 
there is another way to create ZIP file, please, can you show me?

Original comment by amirs...@gmail.com on 7 Jan 2011 at 3:53

GoogleCodeExporter commented 9 years ago
Can you attach the file you created to the issue? Did you try to let winzipaes 
do the zipping by using one of the add methods?

Original comment by olaf.merkert on 7 Jan 2011 at 4:04

GoogleCodeExporter commented 9 years ago
Hello,

I tried to use add method and it works for smaller files. But few MB files 
throw OutOfMemory exception.  Then I tried addAll method with ZIP file that is 
created with java.util.zip. What should I do?

Original comment by amirs...@gmail.com on 7 Jan 2011 at 6:47

GoogleCodeExporter commented 9 years ago
Here is ZIP file but I ge the same results for other ZIP files created with 
java.util.zip.

Original comment by amirs...@gmail.com on 7 Jan 2011 at 7:02

Attachments:

GoogleCodeExporter commented 9 years ago
And I forgot to say that this is happening on the Android OS.

Original comment by amirs...@gmail.com on 7 Jan 2011 at 8:04

GoogleCodeExporter commented 9 years ago
created a new issue 29 - this is an android only problem

Original comment by olaf.merkert on 8 Jan 2011 at 9:33