proc_open to return an encrypted string?
| From: | Robert Van Overmeiren | Date: | Mon, 06 Oct 2003 15:35:58 +0000 |
| Subject: | proc_open to return an encrypted string? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-165189@lists.php.net to get a copy of this message | ||
Hello,
I want to take a String variable and GPG encrypt it, then email the
encrypted string.
One of our developers suggested using "proc_open" and to "set the process to
'gpg -a --encrypt -r 0x35E891B0'", but couldn't clarify.
How is this done? Would it be something like this...?
-----------------------------------------
$message = "Text or HTML string";
$pipes = "-a --encrypt -r 0x35E891B0";
$descriptorspec = array(0 => array("pipe", "r"), 1 =>
array("pipe", "w"), 2
=> array("file", "/tmp/error-output.txt", "a"));
$process = proc_open("gpg", $descriptorspec, $pipes);
if (is_resource($process)) {
fwrite($pipes[0], $message);
fclose($pipes[0]);
while(!feof($pipes[1])) {
echo fgets($pipes[1], 1024);
}
fclose($pipes[1]);
$return_value = proc_close($process);
}
send_mail($smtp_server, $smtp_port, $sender_email, $recipient_email,
$subject, $message, $headers);
----------------------------------------
Thank you,
Bob Van