Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net.lingala.zip4j.exception.ZipException: Reached end of entry, but crc verification failed for test.txt #513

Open
thePK opened this issue Aug 29, 2023 · 1 comment

Comments

@thePK
Copy link

thePK commented Aug 29, 2023

For the encrypted compressed zip file, is it supported to use zinInputstream to decompress it directly? Below is my test code and maven dependency, I received the following error. But the same code will work fine for an unencrypted zip package.

maven dependency:

net.lingala.zip4j
zip4j
2.9.1

test code:
public static void main(String[] args) {
String srcPath = "E:\test1.zip";
try {
ZipInputStream zis = new ZipInputStream(new FileInputStream(srcPath), "123".toCharArray());
LocalFileHeader nextEntry = zis.getNextEntry();
while (Objects.nonNull(nextEntry)) {
String fileName = nextEntry.getFileName();
if (!nextEntry.isDirectory()) {
log.info("entry name {}", fileName);
}
nextEntry = zis.getNextEntry();
}
} catch (IOException e) {
e.printStackTrace();
}
}

Error reported:
net.lingala.zip4j.exception.ZipException: Reached end of entry, but crc verification failed for test.txt

@thePK
Copy link
Author

thePK commented Aug 29, 2023

Sorry about the format before.

For the encrypted compressed zip file, is it supported to use zinInputstream to decompress it directly? Below is my test code and maven dependency, I received the following error. But the same code will work fine for an unencrypted zip package.

maven dependency:

<dependency>
            <groupId>net.lingala.zip4j</groupId>
            <artifactId>zip4j</artifactId>
            <version>2.9.1</version>
        </dependency>

test code:

public static void main(String[] args) {
        String srcPath = "E:\\test1.zip";
        try {
            ZipInputStream zis = new ZipInputStream(new FileInputStream(srcPath), "123".toCharArray());
            LocalFileHeader nextEntry = zis.getNextEntry();
            while (Objects.nonNull(nextEntry)) {
                String fileName = nextEntry.getFileName();
                if (!nextEntry.isDirectory()) {
                    log.info("entry name {}", fileName);
                }
                nextEntry = zis.getNextEntry();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Error reported:

net.lingala.zip4j.exception.ZipException: Reached end of entry, but crc verification failed for test.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant