Create the gnuPG object.
Set the program path for the GNUPG and the home directory of the keyring. If this parameters are not specified, according to the OS the function derive the values.
void
gnuPG
([string $program_path = false], [string $home_directory = false])
-
string
$program_path: Full program path for the GNUPG
-
string
$home_directory: Home directory of the keyring
Decrypt the data.
If the decrypted file is signed, the signature is also verified.
mixed
Decrypt
(string $KeyID, string $Passphrase, string $Text)
-
string
$KeyID: the key id to decrypt
-
string
$Passphrase: the passphrase to open the key used to decrypt
-
string
$Text: data to decrypt
Remove key from the public keyring.
If secret is specified it try to remove the key from from the secret and public keyring. The returned error codes are:
- = no such key
- = must delete secret key first
- = ambiguos specification
mixed
DeleteKey
(string $KeyID, [string $KeyKind = 'public'])
-
string
$KeyID: the key id to be removed, if this is the secret key you must specify the fingerprint
-
string
$KeyKind: the kind of the keys, can be secret or public
Encrypt and sign data.
mixed
Encrypt
(string $KeyID, string $Passphrase, string $RecipientKeyID, string $Text)
-
string
$KeyID: the key id used to encrypt
-
string
$Passphrase: the passphrase to open the key used to encrypt
-
string
$RecipientKeyID: the recipient key id
-
string
$Text: data to encrypt
Export a key.
Export all keys from all keyrings, or if at least one name is given, those of the given name.
mixed
Export
([string $KeyID = false])
-
string
$KeyID: The Key ID to export
Generate a new key pair.
mixed
GenKey
(string $RealName, string $Comment, string $Email, [string $Passphrase = ''], string $ExpireDate, [string $KeyType = 'DSA'], [int $KeyLength = 1024], [string $SubkeyType = 'ELG-E'], [int $SubkeyLength = 1024])
-
string
$RealName: The real name of the user or key.
-
string
$Comment: Any explanatory commentary.
-
string
$Email: The e-mail for the user.
-
string
$Passphrase: Passphrase for the secret key, default is not to use any passphrase.
-
string
$ExpireDate: Set the expiration date for the key (and the subkey). It may either be entered in ISO date format (2000-08-15) or as number of days, weeks, month or years (<number>[d|w|m|y]). Without a letter days are assumed.
-
string
$KeyType: Set the type of the key, the allowed values are DSA and RSA, default is DSA.
-
int
$KeyLength: Length of the key in bits, default is 1024.
-
string
$SubkeyType: This generates a secondary key, currently only one subkey can be handled ELG-E.
-
int
$SubkeyLength: Length of the subkey in bits, default is 1024.
Import/merge keys.
This adds the given keys to the keyring. New keys are appended to your keyring and already existing keys are updated. Note that GnuPG does not import keys that are not self-signed.
mixed
Import
(string $KeyBlock)
-
string
$KeyBlock: The PGP block with the key(s).
Get the keys from the KeyRing.
The returned array get the following elements: [RecordType, CalculatedTrust, KeyLength, Algorithm, KeyID, CreationDate, ExpirationDate, LocalID, Ownertrust, UserID]
mixed
ListKeys
([string $KeyKind = 'public'])
-
string
$KeyKind: the kind of the keys, can be secret or public
Make a signature on key.
If the key is not yet signed by the specified user.
bool
SignKey
(string $KeyID, string $Passphrase, string $KeyIDToSign, [int $CheckLevel = 0])
-
string
$KeyID: the key id used to sign
-
string
$Passphrase: the passphrase to open the key used to sign
-
string
$KeyIDToSign: the key to be signed
-
int
$CheckLevel: the check level (0, 1, 2, 3 -casual to extensive-)