大网数据广告活动
PHP 语言与运行手册

rnp_op_generate_key · Generate key

· 52CE 我爱测

PGP User ID - text that is intended to represent the name and email address of the key holder.

rnp_op_generate_key

(PECL rnp >= 0.1.1)

rnp_op_generate_key — Generate key

Description

function rnp_op_generate_key(
    RnpFFI $ffi,
    string $userid,
    string $key_alg,
    string $sub_alg = ?,
    array $options = ?
): string|false

Parameters

ffi

The FFI object returned by rnp_ffi_create().

userid

PGP User ID - text that is intended to represent the name and email address of the key holder.

key_alg

Primary key algorithm (i.e. 'RSA', 'DSA', etc).

sub_alg

Subkey algorithm. If not set, subkey will not be generated.

options

An associative array with options.

Key Data type Description
"bits" integer Primary key size in bits. Applicable only to RSA, DSA and El-Gamal keys.
"hash" string Hash algorithm used in self signature or subkey binding signature.
"dsa_qbits" integer Set size of a q parameter for DSA key. Note: appropriate default value will be set, depending on key bits. However you may override it if needed.
"curve" string Set the curve used for ECC key. Note: this is only applicable for ECDSA, ECDH and SM2 keys.
"request_password" boolean Enable requesting password via password provider. This password will be used for key encryption. Password provider callback function should be set in advance by calling rnp_ffi_set_pass_provider(). Note: this setting will be ignored if password was set via"password"
"password" string Set the password used to encrypt the secret key data.
"expiration" integer Set the key and subkey expiration time in seconds.
"sub_bits" integer Subkey size in bits. Applicable only to RSA, DSA and El-Gamal keys.
"sub_hash" string Hash algorithm used in subkey self signature or subkey binding signature.
"sub_curve" string Set the curve used for ECC subkey. Note: this is only applicable for ECDSA, ECDH and SM2 keys.

Return Values

Fingerprint of the generated primary key or false on failure. This fingerprint can be used later to reference the key in sign and encrypt operations. The key data is stored in FFI memory context and can be saved using rnp_save_keys() or rnp_save_keys_to_path().

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。