openssl_open
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
openssl_open — 打開密封的數據
說明
   openssl_open(
string
string
string
mixed
string
string
): bool
  string
$sealed_data,string
&$open_data,string
$env_key,mixed
$priv_key_id,string
$method = "RC4",string
&$iv = ?): bool
   openssl_open() 使用與金鑰識別符號priv_key_id和信封金鑰env_key相關聯的私鑰打開 (解密)
   sealed_data 數據, 使用解密后的數據填充open_data。
   當數據被密封時,就產生了信封金鑰且只能由一個特定的私鑰使用。更多資訊參見
   openssl_seal() 。
  
參數
- 
sealed_data
- 
      
- 
open_data
- 
      如果呼叫成功,則在這個參數中返回打開的數據。 
- 
env_key
- 
      
- 
priv_key_id
- 
      
- 
method
- 
      加解密演算法。 
- 
iv
- 
      初始化向量。 
返回值
   成功時返回 true, 或者在失敗時返回 false。
  
更新日誌
| 版本 | 說明 | 
|---|---|
| 7.0.0 | 新增了 iv參數 | 
| 5.3.0 | 新增了 method參數 | 
範例
示例 #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);
?>