コード例 #1
0
 public function decrypt($string)
 {
     $user = new User();
     $gpg = new gnupg();
     $gpg->adddecryptkey($user->getPrivatekey());
     $decryptedString = $gpg->decrypt($string);
     return $decryptedString;
 }
コード例 #2
0
ファイル: Crypt.php プロジェクト: andyburton/sonic-framework
 /**
  * GnuPG decrypt a message using the recipient private key
  * http://devzone.zend.com/article/3753-Using-GnuPG-with-PHP
  * NOTE: GnuPG must be installed and configured with PHP.
  *       The recipient must be in your private key ring
  * @param string $recipient Recipient Indentity (e.g. email address)
  * @param string $recipientKey Recipient Secret Key
  * @param string $message Message to decrypt
  * @return string
  */
 public static function _decryptGnuPG($recipient, $recipientKey, $message)
 {
     // Create new GnuPG object
     $gpg = new \gnupg();
     // Set error mode
     $gpg->seterrormode(\gnupg::ERROR_EXCEPTION);
     // Add the recipient decryption key
     $gpg->adddecryptkey($recipient, $recipientKey);
     // Return decrypted data
     return $gpg->decrypt($message);
 }