Пример #1
0
 /**
  * Encrypt the body of an email.
  *
  * @param Message $message
  * @return Message
  */
 public function decrypt(Message $message) : Message
 {
     $gnupg = new \Crypt_GPG($this->options);
     $gnupg->addDecryptKey($this->serverKeyFingerprint);
     // Replace the message with its encrypted counterpart
     $decrypted = $gnupg->decrypt($message->getBodyText());
     return $message->setBody($decrypted);
 }
Пример #2
0
 /**
  * Decrypt given data
  *  
  * @param string $string
  * @param string $keyPassword
  * @param string $keyID
  * @return string
  */
 public static function decrypt($string, $keyPassword = null, $keyID = null)
 {
     $gpg = new Crypt_GPG();
     if ($keyID === null) {
         $keyID = ConfigManager::getConfig("Crypto", "GPG")->AuxConfig->defaultKey;
     }
     if ($keyPassword === null) {
         $keyPassword = ConfigManager::getConfig("Crypto", "GPG")->AuxConfig->defaultKeyPasswd;
     }
     $gpg->addDecryptKey($keyID, $keyPassword);
     return $gpg->decrypt($string);
 }