public function decrypt($string)
 {
     $user = new User();
     $gpg = new gnupg();
     $gpg->adddecryptkey($user->getPrivatekey());
     $decryptedString = $gpg->decrypt($string);
     return $decryptedString;
 }
Esempio n. 2
0
 /**
  * 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);
 }