Skip to content

Commit

Permalink
Add Horde_Pgp_Mime#publicKeyPart()
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Apr 17, 2015
1 parent 8f4bb6b commit 8b3249b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions framework/Pgp/lib/Horde/Pgp/Mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,25 @@ public function signAndEncryptPart(
return $base;
}

/**
* Generate a Horde_Mime_Part object that contains a public key (RFC
* 3156 [7]).
*
* @param mixed $key The public key.
*
* @return Horde_Mime_Part An object that contains the public key.
*/
public function publicKeyPart($key)
{
$key = Horde_Pgp_Element_PublicKey::create($key);

$part = new Horde_Mime_Part();
$part->setType('application/pgp-keys');
$part->setHeaderCharset('UTF-8');
$part->setDescription(Horde_Crypt_Translation::t("PGP Public Key"));
$part->setContents(strval($key), array('encoding' => '7bit'));

return $part;
}

}

0 comments on commit 8b3249b

Please sign in to comment.