我真的很想安全地解决这个问题,因为涉及到客户数据。
我正在通过命令行使用 GNUPG,因为我在共享主机上,并且 PHP 类不可用。所以我的代码如下:
putenv("GNUPGHOME=/home/me/.gnupg");
$gpg = '/usr/bin/gpg';
$gpgrecipient = 'email';
$mailrecp = 'email';
$plain = 'Here is the encrypted Text Here is the encrypted Text Here is the
encrypted Text Here is the encrypted Text Here is the encrypted Text Here is the
encrypted Text Here is the encrypted Text Here is the encrypted Text Here is the
encrypted Text';
$encrypted = shell_exec("echo {$plain} | {$gpg} --no-auto-check-trustdb --lock-never -e -a -r {$gpgrecipient} ");
那么,我该如何进行转义$plain
,同时保持数据完整性?
如果我只是使用escapeshellcmd()
它往往会弄乱格式。
我有点担心将任何内容保存到文件中,因为它是共享主机上的敏感数据。