Crypt/GPG.php
public function getFingerprint($keyId, $format = self::FORMAT_NONE)
    {
        $output    = '';
        $operation = '--list-keys ' . escapeshellarg($keyId);
        $arguments = array(
            '--with-colons',
            '--with-fingerprint'
        );

        $this->engine->reset();
        $this->engine->setOutput($output);
        $this->engine->setOperation($operation, $arguments);
        $this->engine->run();

        $fingerprint = null;

        foreach (explode(PHP_EOL, $output) as $line) {
            if (mb_substr($line, 0, 3, '8bit') == 'fpr') {
                $lineExp     = explode(':', $line);
                $fingerprint = $lineExp[9];

                switch ($format) {
                case self::FORMAT_CANONICAL:
                    $fingerprintExp = str_split($fingerprint, 4);
                    $format         = '%s %s %s %s %s  %s %s %s %s %s';
                    $fingerprint    = vsprintf($format, $fingerprintExp);
                    break;

                case self::FORMAT_X509:
                    $fingerprintExp = str_split($fingerprint, 2);
                    $fingerprint    = implode(':', $fingerprintExp);
                    break;
                }

                break;
            }
        }

        return $fingerprint;
    }
public function getFingerprint($keyId, $format = self::FORMAT_NONE)
    {
        $output    = '';
        $operation = '--list-keys ' . escapeshellarg($keyId);
        $arguments = array(
            '--with-colons',
            '--with-fingerprint'
        );

        $this->engine->reset();
        $this->engine->setOutput($output);
        $this->engine->setOperation($operation, $arguments);
        $this->engine->run();

        $fingerprint = null;

        foreach (explode(PHP_EOL, $output) as $line) {
            if (mb_substr($line, 0, 3, '8bit') == 'fpr') {
                $lineExp     = explode(':', $line);
                $fingerprint = $lineExp[9];

                switch ($format) {
                case self::FORMAT_CANONICAL:
                    $fingerprintExp = str_split($fingerprint, 4);
                    $format         = '%s %s %s %s %s  %s %s %s %s %s';
                    $fingerprint    = vsprintf($format, $fingerprintExp);
                    break;

                case self::FORMAT_X509:
                    $fingerprintExp = str_split($fingerprint, 2);
                    $fingerprint    = implode(':', $fingerprintExp);
                    break;
                }

                break;
            }
        }

        return $fingerprint;
    }
Gets a key fingerprint from the keyring

If more than one key fingerprint is available (for example, if you use
a non-unique user id) only the first key fingerprint is returned.

Calls the GPG <kbd>--list-keys</kbd> command with the
<kbd>--with-fingerprint</kbd> option to retrieve a public key
fingerprint.

@param string  $keyId  either the full user id of the key, the email
part of the user id of the key, or the key id of
the key. For example,
"Test User (example) <test@example.com>",
"test@example.com" or a hexadecimal string.
@param integer $format optional. How the fingerprint should be formatted.
Use {@link Crypt_GPG::FORMAT_X509} for X.509
certificate format,
{@link Crypt_GPG::FORMAT_CANONICAL} for the format
used by GnuPG output and
{@link Crypt_GPG::FORMAT_NONE} for no formatting.
Defaults to <code>Crypt_GPG::FORMAT_NONE</code>.

@return string the fingerprint of the key, or null if no fingerprint
is found for the given <kbd>$keyId</kbd>.

@throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
Use the <kbd>debug</kbd> option and file a bug report if these
exceptions occur.