I have a script which encrypts a message successfully as shown below. What I really need is to sign the message, with the message still readable and the signature shown below.

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("/bin/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("/path/to/.pgp", "key_name", "Hello World"); print nl2br($message);

I think the command to sign the message shold be something like:

$pipe = popen("echo y | /bin/pgps -z  -u $key_id -af ", "r");

The only problem I think is the passphrase, or lack of one, which I'm pretty sure is the only thing stopping the script from working. I've no idea how to get the script to automatically enter the passphrase. 😕

Thank ypu in advance for any help.

    Write a Reply...