(PHP 5 >= 5.6.0, PHP 7, PECL zip >= 1.12.4)
ZipArchive::setPassword — Set the password for the active archive
public ZipArchive::setPassword ( string $password ) : bool
Sets the password for the active archive.
password
The password to be used for the archive.
Returns true
on success or false
on failure.
Note:
As of PHP 7.2.0 and libzip 1.2.0 the password is used to decompress the archive, and is also the default password for ZipArchive::setEncryptionName() and ZipArchive::setEncryptionIndex(). Formerly, this function only set the password to be used to decompress the archive; it did not turn a non-password-protected ZipArchive into a password-protected ZipArchive.
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/ziparchive.setpassword.php