ive tried using popen using bidirectional pipes without working for obvious reasons, but i managed to create a simple script that managed to take care of the problem. This example is for gpg encryption.
<?php
$message = "this is the text to encrypt with gpg";
$sendto = 'Dummy Key <[email protected]>';
system("mkfifo pipein");
system("mkfifo pipeout");
system("gpg --encrypt -a -r '$sendto' > pipeout < pipein &");
$fo = fopen("pipeout", "r");
$fi = fopen("pipein", "w");
fwrite($fi, $message, strlen($message));
fclose($fi);
while (!feof($fo)) {
$buf .= fread($fo, 1024);
}
echo $buf;
unlink("pipein");
unlink("pipeout");
?>
If anyone has a better way of doing this I would love to see it.