PHP ZipArchive Extension now Support Encryption


In a recent blog post, Remi Collet pointed to the latest development of the ZipArchive PHP extension which now support encryption. New features are still experimental and might change, so it’s not yet ready for production. The new feature implementation is based on libzip library new version 1.2.0, and will be shipped with Zip extension version 1.14.0 and most probably with PHP 7.2 as the code is already available in the php_master. You can install the new experimental features from remi’s test RPM or from sources in github :

Three methods are available to manage encryption :

Encryption method being one of the new constants:  ZipArchive::EM_NONE, ZipArchive::EM_AES_128, ZipArchive::EM_AES_192 or ZipArchive::EM_AES_256. The new implementation support adding a per file password or using a default global password. To encrypt an archive you can write the following code :

This new feature seems really useful and will improve compatibility with other tools, such as WinZip for Windows or 7za for Linux.