decrypting a symmetric key from the command line in a script

Adam Cadieux acadieux@pcguardian.com
Tue Aug 26 02:20:01 2003


Instead of decrypting a file I want to store the encrypted data in a
database, and write a script that will decrypt it.

This works fine:
//Decrypt data from a file with a symmetric key in PHP
$results = exec("echo '$password' | /usr/bin/gpg --passphrase-fd 0 --batch
--yes -d /tmp/crypt2.gpg");

But I can't seem to get this to work:

//Decrypt data from a variable with a symmetric key in PHP
<?php

$encrypted_data = "-----BEGIN PGP MESSAGE----- Version: GnuPG v1.0.6
(GNU/Linux) Comment: For info see http://www.gnupg.org
jA0EAwMCGP4cuhKM/+dgySINGrMuDol3KYTkeKKz5kvEPYZjoM+I/+fH65t2K7ve folW =3b9z
-----END PGP MESSAGE-----";

$results = exec("echo '$password' | /usr/bin/gpg --passphrase-fd 0 --batch
--yes -d '$encrypted_data'");
echo ($results);
?>

I have tried using -t, --set-filename, --utf8-string, -a

Not quite sure what I am doing wrong. Thanks for any suggestions,

Cheers,

Adam Cadieux