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

Working with encrypted archives using external libraries #285

Open
HimeWorks opened this issue Apr 25, 2016 · 2 comments
Open

Working with encrypted archives using external libraries #285

HimeWorks opened this issue Apr 25, 2016 · 2 comments
Labels

Comments

@HimeWorks
Copy link

HimeWorks commented Apr 25, 2016

There are JS libraries available for various encryption algorithms.

My understanding of how JSZip works is when I ask for a file to be loaded from the archive, it will automatically be decompressed for me.

I believe zip files are encrypted after they are compressed, so I will need to perform decryption before the decompression occurs.

Would it be possible to

  1. Provide an option to allow encrypted archives (simple flag), provided that
  2. We will be providing methods that will be executed BEFORE or AFTER the decompression occurs

So for example, I might set a beforeDecompress listener so that whenever async is called, it will grab the entry, run it through the callback, and then proceed to decompress it as usual.

My assumption is that the file directory can be read the same way as a zip archive without any encrypted entries.

@dduponchel
Copy link
Collaborator

You are correct, the content is compressed then encrypted.
With a traditional PKWARE encryption, the header (needed to decrypt the file) is in the data section. With WinZip's AES encryption, the header is as an extra data of the entry. The metadata (local file headers, central directory) are only encrypted by PKWARE Strong Encryption but it's covered by a patent: we can ignore it.

JSZip uses internally a stream (async accumulates the result) but the idea is the same. This would need #248 (to get the header).
In that case, we could "register" an object with a supports(zip entry) method and a transform(data) method. The same could be done with the compression.

See also #115.

@xqdoo00o
Copy link
Contributor

xqdoo00o commented Mar 11, 2020

I add some Aes decryption code, please see at #696. But I'm not sure if the code flow is right😂

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

No branches or pull requests

3 participants