Search code examples
pythonzipcompressionzlibdeflate

Possible to have a password-protected/weak-encrypted ZIP file with a data descriptor?


Is it possible to have ZIP file that has a data descriptor, and so the compressed size of each file is after its data, and have it password-protected via ZIP's "weak" encryption mechanism?

Context: am working on a streaming unZIP function for Python, specifically adding decryption support. Not being able to depend on the compressed size known before the data makes it... awkward.


Solution

  • Yes.

    UEsDBC0ACQAIAPBaJFMAAPBa//////////8BABQALQEAEAAAAAAAAAAAAAAAAAAAAAAAiTFa
    LaeEC1Hn3rkwrUpSKqBmSpAtoQ1LulBLBwidP2y1GQAAAAAAAAAOAAAAAAAAAFBLAQIeAy0A
    CQAIAPBaJFOdP2y1GQAAAA4AAAABAAAAAAAAAAAAAACwEQAAAAAtUEsFBgAAAAABAAEALwAA
    AGQAAAAAAA==
    

    Made with Info-ZIP's zip thusly:

    echo -n 'hello, hello!\0' | zip -e | cat > foo.zip
    

    (password: foo)