function login($sig, $key, $text) { # Set this to a private directory outside of the webroot. Make sure the permissions are correct putenv("GNUPGHOME=/var/www/clients/client0/web5/private/.gnupg"); $res = gnupg_init(); gnupg_seterrormode($res, GNUPG_ERROR_WARNING); gnupg_import($res, $key); $info = gnupg_verify($res, $text, $sig); $key = gnupg_keyinfo($res, $info[fingerprint])[0]; $id = $key["subkeys"][0]["keyid"]; $uid = $key["uids"][0]; print " KeyId: " . $id; var_dump($uid); }
function __construct($match = '') { $this->gpg = gnupg_init(); $this->keys = gnupg_keyinfo($this->gpg, $match); }
<?php $email = '*****@*****.**'; $g = gnupg_init(); $keys = gnupg_keyinfo($g, $email); if (count($keys) == 1) { $fingerprint = $keys[0]['subkeys'][0]['fingerprint']; print "Fingerprint for {$email} is {$fingerprint}"; } else { print "Expected 1, found " . count($keys) . " keys for {$email}"; }