= 4.0.4, PHP 5, PHP 7, PHP 8)openssl_open — 打開(kāi)密封的數(shù)據(jù)說(shuō)明openssl_open( string $sealed_data, string &$open_data, string $env_k">

openssl_open

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

openssl_open打開(kāi)密封的數(shù)據(jù)

說(shuō)明

openssl_open(
    string $sealed_data,
    string &$open_data,
    string $env_key,
    mixed $priv_key_id,
    string $method = "RC4",
    string &$iv = ?
): bool

openssl_open() 使用與密鑰標(biāo)識(shí)符priv_key_id和信封密鑰env_key相關(guān)聯(lián)的私鑰打開(kāi) (解密) sealed_data 數(shù)據(jù), 使用解密后的數(shù)據(jù)填充open_data。 當(dāng)數(shù)據(jù)被密封時(shí),就生成了信封密鑰且只能由一個(gè)特定的私鑰使用。更多信息參見(jiàn) openssl_seal()

參數(shù)

sealed_data

open_data

如果調(diào)用成功,則在這個(gè)參數(shù)中返回打開(kāi)的數(shù)據(jù)。

env_key

priv_key_id

method

加解密算法。

iv

初始化向量。

返回值

成功時(shí)返回 true, 或者在失敗時(shí)返回 false。

更新日志

版本 說(shuō)明
7.0.0 添加了 iv 參數(shù)
5.3.0 添加了 method 參數(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($fp8192);
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);
?>

參見(jiàn)