(PHP 4 >= 4.0.4, PHP 5, PHP 7)
openssl_open — ���ܷ������
$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 ����
|
Example #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);
?>