W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
openssl_open — 打開密封的數(shù)據(jù)
openssl_open(
string $data,
string &$output,
string $encrypted_key,
OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key,
string $cipher_algo,
?string $iv = null
): bool
openssl_open() 使用與密鑰標識符 private_key 和信封密鑰 encrypted_key 相關聯(lián)的私鑰打開(解密)data 數(shù)據(jù), 使用解密后的數(shù)據(jù)填充 output。當數(shù)據(jù)被密封時,就生成了信封密鑰且只能由一個特定的私鑰使用。更多信息參見openssl_seal()。
data
output
如果調用成功,則在這個參數(shù)中返回打開的數(shù)據(jù)。
encrypted_key
private_key
cipher_algo
加解密算法。
默認值('RC4'
)認為不安全。強烈建議明確指定安全密碼方法。
iv
初始化向量。
成功時返回 true, 或者在失敗時返回 false。
版本 | 說明 |
---|---|
8.0.0 | private_key 現(xiàn)在接受 OpenSSLAsymmetricKey 或 OpenSSLCertificate 實例;之前接受類型 OpenSSL key 或 OpenSSL X.509 CSR 的 resource。 |
8.0.0 | cipher_algo 不再是可選參數(shù)。 |
示例 #1 openssl_open() 示例
<?php
// $sealed and $env_key are assumed to contain the sealed data
// and our envelope key, both given to us by the sealer.
// fetch private key from file and ready it
$fp = fopen("/src/openssl-0.9.6/demos/sign/key.pem", "r");
$priv_key = fread($fp, 8192);
fclose($fp);
$pkeyid = openssl_get_privatekey($priv_key);
// decrypt the data and store it in $open
if (openssl_open($sealed, $open, $env_key, $pkeyid)) {
echo "here is the opened data: ", $open;
} else {
echo "failed to open data";
}
// free the private key from memory
openssl_free_key($pkeyid);
?>
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: