note 21730 added to function.popen

From: Date: Fri, 24 May 2002 15:49:10 +0000
Subject: note 21730 added to function.popen
Groups: php.notes 
Request: Send a blank email to php-notes+get-30996@lists.php.net to get a copy of this message
I had all kinds of trouble encrypting a message with PGP, but I finanlly got it to work. The trick was to 'chmod o+r pubring.pkr' so that the apache server could read the public keys!!! Then, this function worked fine: <?PHP function pgp_encrypt($keyring_location, $public_key_id, $plain_text) { $key_id = EscapeShellArg($public_key_id); putenv("PGPPATH=$keyring_location"); // encrypt the message $pipe = popen("pgpe -r $key_id -af", "r"); fwrite($pipe, $plain_text); $encrypted_text = ''; while($s = fgets($pipe, 1024)) { // read from the pipe $encrypted_text .= $s; } pclose($pipe); return $encrypted_text; } $message = pgp_encrypt("/home/username/.pgp", "to@domain.com", "dummy text to be encrypted"); print nl2br($message); ?> -- http://www.php.net/manual/en/function.popen.php http://master.php.net/manage/user-notes.php?action=edit+21730 http://master.php.net/manage/user-notes.php?action=delete+21730 http://master.php.net/manage/user-notes.php?action=reject+21730

« previous php.notes (#30996) next »