2012-02-18 63 views
0

我想在PHP中第一次实现pgp加密,但我很难使其工作。我希望有人能够指引我正确的方向。基本上,如果我这样做:从PHP内使用PGP加密

$gpg = '/usr/bin/gpg'; 

    $recipient = '[email protected]'; 

    $encrypted_message = shell_exec("echo 'a_string_here' | $gpg -e -r $recipient"); 

    echo $encrypted_message; 

它工作正常。在服务器上为[email protected]安装公钥和私钥。然而,如果我这样做,我得到一个空变量

$gpg = '/usr/bin/gpg'; 

    $recipient = '[email protected]'; 

    $encrypted_message = shell_exec("echo 'a_string_here' | $gpg -e -r $recipient"); 

    echo $encrypted_message; 

只有一个公钥安装[email protected]。当然,我需要这个[email protected]这是加密的字符串的收件人提前

回答