Back to SodiumCipher class

Method generateKey

public \Joomla\Crypt\Key
generateKey
(array $options = array())
Method to generate a new encryption key object.
Parameters
  • array $options Key generation options.
Returns
  • \Joomla\Crypt\Key
Since
  • 3.8.0
-
  • \RuntimeException
Class: SodiumCipher
Project: Joomla

Method generateKey - Source code

/**
 * Method to generate a new encryption key object.
 *
 * @param   array  $options  Key generation options.
 *
 * @return  Key
 *
 * @since   3.8.0
 * @throws  \RuntimeException
 */
public function generateKey(array $options = array())
{
    // Generate the encryption key.
    $pair = Compat::crypto_box_keypair();
    return new Key('sodium', Compat::crypto_box_secretkey($pair), Compat::crypto_box_publickey($pair));
}