Reputation: 1003
I would like to know how can i decrypt a file by passing the passphrase/secret key in the command line.
I tried using this, but its still giving me a prompt to enter the passphrase.
echo shell_exec("echo $passphrase | gpg --passphrase-fd 0 -o $unencrypted_file -d $encrypted_file");
My goal is to created a program in PHP that can decrypt the files automatically.
Upvotes: 1
Views: 3816
Reputation: 782
gpg --passphrase-file $file
man gpg says : "Read the passphrase from file file. Only the first line will be read from file file. This can only be used if only one passphrase is supplied. Obviously, a passphrase stored in a file is of questionable security if other users can read this file. Don't use this option if you can avoid it."
Upvotes: 0
Reputation: 15989
I don't know what approach the gpg developers were using to prevent that. But as an alternative you can use this PHP module: http://pecl.php.net/package/gnupg to handle the decryption. See also http://php.net/gnupg
Upvotes: 0