0

php中的system()调用用于调用外部程序。如何通过php脚本调用gpg(gnupg命令)进行加密。

4

3 回答 3

1

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.

于 2010-03-19T12:15:37.663 回答
1

http://php.net/manual/en/book.gnupg.php

于 2010-03-19T07:49:19.827 回答
0

我用来做这样的事

$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
}

假设常量 PGP_BIN_PATH 定义了 pgp 二进制文件的路径,而 PGP_RECIPIENT 是目标名称,我认为它必须首先被 PGP 知道。

于 2010-03-19T09:08:24.193 回答