(PHP 4 >= 4.0.4, PHP 5, PHP 7)
openssl_seal — �ܷ� (����) ����
$data
, string &$sealed_data
, array &$env_keys
, array $pub_key_ids
[, string $method = "RC4"
[, string &$iv
]] ) : int
openssl_seal() ʹ��������ɵ���Կ������ method �����ܷ� (����)
data ���ݡ� ��Կ����pub_key_ids�еı�ʶ���������ÿ��������Կ���ܣ�����ÿ��������Կ��env_keys�з��ء� ����ζ��һ���˿��Խ��ܷ�����ݷ������������(���һ�����Ѿ���������ǵĹ�Կ)��ÿ�����շ�������ͬʱ���ռ��ܵ����ݺ��ý��շ��Ĺ�Կ���ܵ��ŷ���Կ��
dataҪ�ܷ�����ݡ�
sealed_data���ܷ������ݡ�
env_keys�ѱ����ܵ���Կ���顣
pub_key_ids��Կ��Դ��ʶ����ɵ����顣
method�����㷨��
iv��ʼ��������
�ɹ��������ܷ�����ݵij��ȣ������� FALSE .
����ܷ������ݳɹ���ͨ��sealed_data�������أ���ô�ŷ���ԿҲ����ͨ�� env_keys �������ء�
| �汾 | ˵�� |
|---|---|
| 7.0.0 |
��� iv ������
|
| 5.3.0 |
��� method ������
|
Example #1 openssl_seal() ������
<?php
// $data is assumed to contain the data to be sealed
// fetch public keys for our recipients, and ready them
$fp = fopen("/src/openssl-0.9.6/demos/maurice/cert.pem", "r");
$cert = fread($fp, 8192);
fclose($fp);
$pk1 = openssl_get_publickey($cert);
// Repeat for second recipient
$fp = fopen("/src/openssl-0.9.6/demos/sign/cert.pem", "r");
$cert = fread($fp, 8192);
fclose($fp);
$pk2 = openssl_get_publickey($cert);
// seal message, only owners of $pk1 and $pk2 can decrypt $sealed with keys
// $ekeys[0] and $ekeys[1] respectively.
openssl_seal($data, $sealed, $ekeys, array($pk1, $pk2));
// free the keys from memory
openssl_free_key($pk1);
openssl_free_key($pk2);
?>