generateKey() public method

Generates a personal Public/Private keypair combination.
public generateKey ( string $realname, string $email, string $passphrase, string $comment = '', integer $keylength = 1024, integer $expire = null, string $key_type = 'RSA', string $subkey_type = 'RSA' ) : array
$realname string The name to use for the key.
$email string The email to use for the key.
$passphrase string The passphrase to use for the key.
$comment string The comment to use for the key.
$keylength integer The keylength to use for the key.
$expire integer The expiration date (UNIX timestamp). No expiration if empty.
$key_type string Key type (@since 2.2.0).
$subkey_type string Subkey type (@since 2.2.0).
return array An array consisting of the following keys/values: - private: (string) Private key. - public: (string) Public key.
Example #1
0
 /**
  * Generate the personal Public/Private keypair and store in prefs.
  *
  * @param string $name        See Horde_Crypt_Pgp::.
  * @param string $email       See Horde_Crypt_Pgp::.
  * @param string $passphrase  See Horde_Crypt_Pgp::.
  * @param string $comment     See Horde_Crypt_Pgp::.
  * @param string $keylength   See Horde_Crypt_Pgp::.
  * @param integer $expire     See Horde_Crypt_Pgp::.
  *
  * @throws Horde_Crypt_Exception
  */
 public function generatePersonalKeys($name, $email, $passphrase, $comment = '', $keylength = 1024, $expire = null)
 {
     $keys = $this->_pgp->generateKey($name, $email, $passphrase, $comment, $keylength, $expire);
     /* Store the keys in the user's preferences. */
     $this->addPersonalPublicKey($keys['public']);
     $this->addPersonalPrivateKey($keys['private']);
 }