I have a zip file that is AES encrypted. After decrypting I'm left with a byte[] containing the zip content. But when I try to unzip it, using a ByteArrayInputStream, ZipInputStream.getNextEntry() returns null right away. Debugging, I see that my byte[] doesn't have a required local file header signature which is
static long LOCSIG = 0x04034b50L; // "PK\003\004"
so ZipInputStream.getNextEntry() returns null.
If, however, I write those decrypted bytes out to a file and then use a FileInputStream() that I pass to ZipInputStream(), everything works as expected. Below is my current code. Can anyone suggest a way to unzip without first writing out to a temporary file?
byte[] data = AESUtil.decryptInputStream(...);
ByteArrayInputStream bis = new ByteArrayInputStream(data);
ZipInputStream stream = new ZipInputStream(bis);
ZipEntry entry;
while ((entry = stream.getNextEntry()) != null) {
...
}