无需言 做自己 业 ,精于勤 荒于嬉.

OpenSSL 函数 openssl_cms_decrypt Decrypt a CMS message

发表日期:2021-07-01 08:55:20 | 来源: | 分类:OpenSSL 函数

openssl_cms_decrypt

(PHP 8)

openssl_cms_decryptDecrypt a CMS message

说明

openssl_cms_decrypt(
    string $input_filename,
    string $output_filename,
    OpenSSLCertificate|string $certificate,
    OpenSSLAsymmetricKey|OpenSSLCertificate|array|string|null $private_key = null,
    int $encoding = OPENSSL_ENCODING_SMIME
): bool

Decrypts a CMS message.

参数

input_filename

The name of a file containing encrypted content.

output_filename

The name of the file to deposit the decrypted content.

certificate

The name of the file containing a certificate of the recipient.

private_key

The name of the file containing a PKCS#8 key.

encoding

The encoding of the input file. One of OPENSSL_CMS_SMIME, OPENSLL_CMS_DER or OPENSSL_CMS_PEM.

返回值

成功时返回 true, 或者在失败时返回 false

阅读全文 »

Hash 函数 hash_final 结束增量哈希,并且返回摘要结果

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

      示例1
<?php 
$ctx = hash_init('sha1');
hash_update($ctx, 'The quick brown fox jumped over the lazy dog.');
echo hash_final($ctx);
?>

阅读全文 »

Hash 函数 hash_copy 拷贝哈希运算上下文

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

      示例1
<?php 
$context = hash_init("md5");
hash_update($context, "data");
/* 拷贝上下文资源以便继续使用 */
$copy_context = hash_copy($context);
echo hash_final($context), "\n";
hash_update($copy_context, "data");
echo hash_final($copy_context), "\n";
?>

阅读全文 »

Hash 函数 hash_init 初始化增量哈希运算上下文

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

      示例1
<?php 
$ctx = hash_init('md5');
hash_update($ctx, 'The quick brown fox ');
hash_update($ctx, 'jumped over the lazy dog.');
echo hash_final($ctx);
?>

阅读全文 »

Hash 函数 hash_hmac_file 使用 HMAC 方法和给定文件的内容生成带密钥的哈希值

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

      示例1
<?php 
/* 创建一个要计算哈希值的文件 */
file_put_contents('example.txt', 'The quick brown fox jumped over the lazy dog.');
echo hash_hmac_file('md5', 'example.txt', 'secret');
?>

阅读全文 »

Hash 函数 hash_hmac 使用 HMAC 方法生成带有密钥的哈希值

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

      示例1
<?php 
echo hash_hmac('ripemd160', 'The quick brown fox jumped over the lazy dog.', 'secret');
?>

阅读全文 »

Hash 函数 hash_pbkdf2 生成所提供密码的 PBKDF2 密钥导出

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

      示例1
<?php 
$password = "password";
$iterations = 1000;
// 使用 openssl_random_pseudo_bytes(),random_bytes(),或者其他合适的随机数生成函数// 来生成随机初始向量$salt = openssl_random_pseudo_bytes(16, MCRYPT_DEV_URANDOM);
$hash = hash_pbkdf2("sha256", $password, $salt, $iterations, 20);
echo $hash;
?>

阅读全文 »

Hash 函数 hash_update_stream 从打开的流向活跃的哈希运算上下文中填充数据

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

      示例1
<?php 
$fp = tmpfile();
fwrite($fp, 'The quick brown fox jumped over the lazy dog.');
rewind($fp);
$ctx = hash_init('md5');
hash_update_stream($ctx, $fp);
echo hash_final($ctx);
?>

阅读全文 »

Hash 函数 hash_update 向活跃的哈希运算上下文中填充数据

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

hash_update

(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)

hash_update向活跃的哈希运算上下文中填充数据

说明

hash_update(HashContext $context, string $data): bool

参数

context

hash_init() 函数返回的哈希运算上下文。

data

要向哈希摘要中追加的数据。

返回值

返回 true

更新日志

版本 说明
7.2.0 接收参数从资源类型修改为 HashContext 对象类型。

参见

阅读全文 »

Hash 函数 hash_update_file 从文件向活跃的哈希运算上下文中填充数据

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

hash_update_file

(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)

hash_update_file从文件向活跃的哈希运算上下文中填充数据

说明

hash_update_file(HashContext $hcontext, string $filename, resource $scontext = null): bool

参数

hcontext

hash_init() 函数返回的哈希运算上下文。

filename

要进行哈希运算的文件路径,支持 fopen 封装器。

scontext

stream_context_create() 函数返回的流上下文。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
7.2.0 接收参数从资源类型修改为 HashContext 对象类型。

参见

阅读全文 »

Hash 函数 hash_equals 可防止时序攻击的字符串比较

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

      示例1
<?php 
$expected  = crypt('12345', '$2a$07$usesomesillystringforsalt$');
$correct   = crypt('12345', '$2a$07$usesomesillystringforsalt$');
$incorrect = crypt('apple', '$2a$07$usesomesillystringforsalt$');
var_dump(hash_equals($expected, $correct));
var_dump(hash_equals($expected, $incorrect));
?>

阅读全文 »

Hash 函数 hash 生成哈希值 (消息摘要)

发表日期:2021-07-01 08:55:16 | 来源: | 分类:Hash 函数

      示例1
<?php 
echo hash('ripemd160', 'The quick brown fox jumped over the lazy dog.');
?>

      示例2
<?php 
function old_tiger($data = "", $width=192, $rounds = 3) {
    return substr(        implode(            array_map(                function ($h) {
                    return str_pad(bin2hex(strrev($h)), 16, "0");
                }
,                str_split(hash("tiger192,$rounds", $data, true), 8)            )        ),        0, 48-(192-$width)/4    );
}
echo hash('tiger192,3', 'a-string'), PHP_EOL;
echo old_tiger('a-string'), PHP_EOL;
?>

阅读全文 »

Hash 函数 hash_file 给指定文件的内容生成哈希值

发表日期:2021-07-01 08:55:15 | 来源: | 分类:Hash 函数

      示例1
<?php 
/* 创建一个要计算哈希值的文件 */
file_put_contents('example.txt', 'The quick brown fox jumped over the lazy dog.');
echo hash_file('md5', 'example.txt');
?>

阅读全文 »

Hash 函数 hash_algos 返回已注册的哈希算法列表

发表日期:2021-07-01 08:55:15 | 来源: | 分类:Hash 函数

      示例1
<?php 
print_r(hash_algos());
?>

阅读全文 »

Hash 函数 hash_hmac_algos Return a list of registered hashing algorithms suitable for hash_hmac

发表日期:2021-07-01 08:55:15 | 来源: | 分类:Hash 函数

      示例1
<?php 
print_r(hash_hmac_algos());


阅读全文 »

Hash 函数 hash_hkdf Generate a HKDF key derivation of a supplied key input

发表日期:2021-07-01 08:55:15 | 来源: | 分类:Hash 函数

      示例1
<?php 
// Generate a random key, and salt to strengthen it during derivation.$inputKey = random_bytes(32);
$salt = random_bytes(16);
// Derive a pair of separate keys, using the same input created above.$encryptionKey = hash_hkdf('sha256', $inputKey, 32, 'aes-256-encryption', $salt);
$authenticationKey = hash_hkdf('sha256', $inputKey, 32, 'sha-256-authentication', $salt);
var_dump($encryptionKey !== $authenticationKey);
 // bool(true)?>

阅读全文 »

Zip 函数 zip_entry_open 打开用于读取的目录实体

发表日期:2021-07-01 08:55:11 | 来源: | 分类:Zip 函数

zip_entry_open

(PHP 4 >= 4.1.0, PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL zip >= 1.0.0)

zip_entry_open打开用于读取的目录实体

说明

zip_entry_open(resource $zip, resource $zip_entry, string $mode = ?): bool

打开ZIP文件中的目录实体以便后续读取。

参数

zip

由函数zip_open()返回的有效的资源句柄。

zip_entry

由函数zip_read()返回的目录实体。

mode

任何在fopen()处理文档中指定的模式。

注意:

由于ZIP在PHP中只支持读取模式,所以mode 实际上总是被设置为"rb"(其他模式会被忽略)。

返回值

成功时返回 true, 或者在失败时返回 false

注意:

fopen()和其他类似的方法不同,zip_entry_open() 的返回值只用于标示该操作结果,不需要读取或关闭该目录实体。

参见

阅读全文 »

Zip 函数 zip_entry_name 检索目录项的名称

发表日期:2021-07-01 08:55:11 | 来源: | 分类:Zip 函数

zip_entry_name

(PHP 4 >= 4.1.0, PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL zip >= 1.0.0)

zip_entry_name检索目录项的名称

说明

zip_entry_name(resource $zip_entry): string

返回指定目录项的名称。

参数

zip_entry

由函数zip_read() 返回的目录项。

返回值

目录项的名称。

参见

阅读全文 »

Zip 函数 zip_entry_compressionmethod 检索目录实体的压缩方法

发表日期:2021-07-01 08:55:11 | 来源: | 分类:Zip 函数

zip_entry_compressionmethod

(PHP 4 >= 4.1.0, PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL zip >= 1.0.0)

zip_entry_compressionmethod检索目录实体的压缩方法

说明

zip_entry_compressionmethod(resource $zip_entry): string

返回由函数zip_entry确定的目录实体的压缩方法。

参数

zip_entry

由函数zip_read() 返回的目录实体。

返回值

压缩方法。

参见

阅读全文 »

Zip 函数 zip_read 读取ZIP存档文件中下一项

发表日期:2021-07-01 08:55:11 | 来源: | 分类:Zip 函数

zip_read

(PHP 4 >= 4.1.0, PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL zip >= 1.0.0)

zip_read读取ZIP存档文件中下一项

说明

zip_read(resource $zip): resource

读取ZIP存档文件中下一项。

参数

zip

一个ZIP压缩文件,该ZIP归档文件之前应由函数 zip_open() 打开。

返回值

成功的时候返回该当前实体资源供zip_entry_... 系列函数后续使用; 如果没有更多的读取项,则会返回 false 如果遇到错误则会返回相应的错误码。

参见

阅读全文 »

全部博文(1589)
集速网 copyRight © 2015-2025 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。