/ / $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);
?php / / On suppose que $data contient les données à sceller / / lecture de la clé publique pour chaque destinataire $fp = fopen( "/ src / openssl-0.9.6 / demos / maurice / cert.pem", "r"); $cert = fread($fp, 8192); fclose($fp); $pk1 = openssl_get_publickey($cert); / / pour le deuxième destinataire $fp = fopen(" / src / openssl-0.9.6 / demos / sign / cert.pem", "r"); $cert = fread($fp, 8192); fclose($fp); $pk2 = openssl_get_publickey($cert); / / scelle le message: seuls, les possessuers de $pk1 et $pk2 peuvent déchiffrer / / le message $sealed avec les clés $ekeys[0] et $ekeys[1] (respectivement). openssl_seal($data, $sealed, $ekeys, array($pk1,$pk2)); / / libère les clés de la mémoire openssl_free_key($pk1); openssl_free_key($pk2);?