Child pages
  • cPanel API 1 Functions - Gpg::genkey
Skip to end of metadata
Go to start of metadata

 

Description

This function generates a GnuPG key. The system saves the key in the user's /home/.gnupg directory.

Warning:

cPanel API 1 is deprecated. We strongly recommend that you do not use cPanel API 1. However, no equivalent function exists in our newer APIs.

Examples


 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
$generate_key = $cpanel->api1('Gpg', 'genkey', array('Helena', 'But what if it was the chicken?', 'user@example.com', '1y', '2048', '12345luggage') ); // Call the function.


Note:

For more information, read our Guide to the LiveAPI System.

 

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
my $generate_key = $cpliveapi->api1('Gpg', 'genkey', ['Helena', 'But what if it was the chicken?', 'user@example.com', '1y', '2048', '12345luggage'] ); # Call the function.


Note:

For more information, read our Guide to the LiveAPI System.

 

 cPanel Tag System (deprecated)


Warning:

In cPanel & WHM version 11.30 and later, cPanel tags are deprecated. We provide this example to help developers move from the old cPanel tag system to our LiveAPI system. We strongly recommend that you only use the LiveAPI system to call the cPanel APIs.

<cpanel Module="Gpg::genkey($FORM('name','comment','email','expire','keysize','passphrase'))">
 Command Line
cpapi1 --user=username Gpg genkey Helena "But what if it was the chicken?" user@example.com 1y 2048 12345luggage


Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (boolean)
1

   

Parameters

ParameterTypeDescriptionPossible valuesExample
namestring

Required

The person for whom to generate the key.

Any string that contains at least five characters.Helena
commentstring

A comment about the key.

Any string.

But what if it was the chicken?
emailstring

Required

The email address to encode.

A valid email address.user@example.com
expirestring

The desired amount of time between the key's creation (when this function runs) and its expiration.

  • #y# years.
  • #m# months.
  • #w# weeks.
  • #d# days.

Note:

Replace # with one or more digits.

1y
keysizeinteger

The new key's size, in bytes.

Note:

Large keys require more time to generate. 

  • 1024
  • 2048
  • 3072
  • 4096
2048
passphrasestringThe key's password.A secure password.12345luggage

Returns

  • 1 — The function succeeded.
  • 0 — The function failed.