首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ZipArchive::setEncryptionName

(PHP >= 7.2, PECL zip >= 1.14.0)

ZipArchive::setEncryptionName - 设置由其名称定义的条目的加密方法

描述

代码语言:javascript
复制
bool ZipArchive::setEncryptionName ( string $name , int $method [, string $password ] )

设置由其名称定义的条目的加密方法。

参数

name

条目的名称。

method

加密方法由ZipArchive::EM_常量之一定义。

password

可选密码,缺省时使用默认密码。

返回值

成功返回TRUE或失败时返回FALSE

示例

本示例创建一个ZIP文件存档test.zip并添加使用AES 256方法加密的文件test.txt。

Example #1 Archive and encrypt a file

代码语言:javascript
复制
<?php
$zip?=?new?ZipArchive();
if?($zip->open('test.zip',?ZipArchive::CREATE)?===?TRUE)?{
????$zip->setPassword('secret');
????$zip->addFile('text.txt');
????$zip->setEncryptionName('text.txt',?ZipArchive::EM_AES_256);
????$zip->close();
????echo?"Ok\n";
}?else?{
????echo?"KO\n";
}
?>

另请参阅

  • ZipArchive::setPassword() - 设置活动归档的密码
  • ZipArchive::setEncryptionIndex() - 设置由其索引定义的条目的加密方法

← ZipArchive::setEncryptionIndex

ZipArchive::setExternalAttributesIndex →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com