system() call in php used to call external program .How can i call gpg (gnupg commands) for encryption through php script.
yeh! this manual giving me the gnupg commands but need to know in what way i can use this commands using system() call in php script/code. also what library i have to use for this.thnks for suggetions.
trainee
2010-03-19 07:56:04
Don't use system when there is a proper API. It is slow, inefficient, and harder to debug.
David Dorward
2010-03-19 08:13:22
A:
Maybe the article Encryption and Decryption using PHP and GnuPG helps you. It shows how to do it with external calls.
Felix Kling
2010-03-19 08:08:46
A:
What I used for doing such
$filepath = '/path/to/FileToEncrypt.txt';
$output_filepath = $filepath . ".pgp";
$cmdline = PGP_BIN_PATH . " -e -r " . PGP_RECIPIENT . " < $filepath > $output_filepath";
exec ($cmdline, $stdout, $return);
if ($return != 0) {
//Something went wrong with execution, report or do wathever needed
}
assumming constants PGP_BIN_PATH defines path to pgp binary and PGP_RECIPIENT is the dest name, I think it must be known by PGP first.
Benoit
2010-03-19 09:08:24
A:
Using the Crypt_GPG package from PEAR ( http://pear.php.net/package/Crypt_GPG ) worked a charm for me a few months ago when I needed to do similar. Using it's API made it much quicker to get things done and also insulated me from making stupid mistakes - namely getting things wrong re getting the arguments/parameters in the wrong order.
kguest
2010-03-19 12:15:37