PHP 未编译 OpenSSL 支持?以下是如何调用 openssl 命令行实用程序来实现相同目标的方法
<?php
$pkey_file='key.pem';
$pkey_pp='netsvc';
$ph=proc_open('openssl rsautl -decrypt -inkey '.
escapeshellarg($pkey_file).' -passin fd:3',array(
0 => array('pipe','r'), 1 => array('pipe','w'), 2 => STDERR,
3 => array('pipe','r'), ),$pipes);
fwrite($pipes[0],$env_key);
fclose($pipes[0]);
fwrite($pipes[3],$pkey_pp);
fclose($pipes[3]);
$env_key='';
while(!feof($pipes[1])){
$env_key.=sprintf("%02x",ord(fgetc($pipes[1])));
}
fclose($pipes[1]);
if($xc=proc_close($ph)){
echo "Exit code: $xc\n";
}
$ph=proc_open('openssl rc4 -d -iv 0 -K '.$env_key,array(
0 => array('pipe','r'), 1 => array('pipe','w'), 2 => STDERR,
),$pipes);
fwrite($pipes[0],$sealed);
fclose($pipes[0]);
$open='';
while(!feof($pipes[1])){
$open.=fgets($pipes[1]);
}
fclose($pipes[1]);
if($xc=proc_close($ph)){
echo "Exit code: $xc\n";
}
echo $open;
?>