3

I have a question about encoding zip files with password, which is available from PHP v 7.2

When I am encoding ZIP with method ZipArchive::setEncryptionName

There are argument method which can be:

  • ZipArchive::EM_AES_128
  • ZipArchive::EM_AES_192
  • ZipArchive::EM_AES_256

Can somebody tell me / explain which to use and why?

I am now using ZipArchive::EM_AES_256 because I am expecting that it is the most secure but my colleague is telling me that he cannot open it (his zip software is not even asking for password).

So is there one which will be working in all the cases? We have software which is used by a lot of people in my country and a lot of old people might get these ZIP files and it is required that they could be opened and that every zip file has a password.

Please consider that they might even use Windows XP etc.

Tonoslav
  • 517
  • 2
  • 6
  • 20
  • 1
    Ok just to state problem is only with Windows File Explorer which can open ZIP files but cannot decode AES encoding and understands only ZipCrypto which is not possible to use with PHP So for not it is impossible to open ZIP files in native windows file explorer when it was created in PHP (with password) – Tonoslav Mar 23 '20 at 13:31

1 Answers1

3

As per your comment, Windows cannot decrypt AES-encrypted archives natively, not even in recent versions such as Windows 10 (see why).

PHP v8.0 adds "traditional pkware encryption" that will allow Windows users to work with files without 3rd party apps (7-Zip, etc).

For PHP v7.x, one needs to either rely on shell commands or use a library that supports ZipCrypto encryption algorithm (sometimes called "pkware" - as per the company that created the zip format). Several out of the most popular zip libraries on packagist use ext-zip, so they won't offer PKWARE encryption on PHP 7.x. However nelexa/zip doesn't and it supports pkware encryption.

MicE
  • 5,038
  • 2
  • 29
  • 26