牛牛在线工具

openssl_spki_export()

收录 8868 个 PHP 函数,含用途说明与用法示例。

openssl_spki_export()

将SPKI(SubjectPublicKeyInfo)结构导出为字符串

函数名:openssl_spki_export() 适用版本:PHP 7.4.0+ 函数描述:此函数用于将SPKI(SubjectPublicKeyInfo)结构导出为字符串。 用法: openssl_spki_export(resource $spki, string &$out [, bool $notext = TRUE]) : bool 参数: $spki:SPKI资源,可以通过openssl_spki_new()函数创建。 $out:导出的SPKI结构字符串将被存储在此变量中。 $notext(可选):如果设置为FALSE,则函数将在导出字符串中包含有关密钥的文本描述。默认值为TRUE。 返回值:成功时返回TRUE,失败时返回FALSE。 示例: // 创建SPKI结构 $privateKey = openssl_pkey_new(); $spki = openssl_spki_new($privateKey); // 导出SPKI结构为字符串 $exportedSpki = ''; if (openssl_spki_export($spki, $exportedSpki)) { echo "SPKI导出成功:\n"; echo $exportedSpki; } else { echo "SPKI导出失败!"; } 以上示例中,首先使用openssl_pkey_new()函数创建了一个私钥,然后使用openssl_spki_new()函数创建了一个SPKI结构。最后,使用openssl_spki_export()函数将SPKI结构导出为字符串,并打印出来。 请注意,此函数仅在PHP版本7.4.0及以上可用。