Crypt/GPG.php
protected function _exportKey($keyId, $armor = true, $private = false)
    {
        $fingerprint = $this->getFingerprint($keyId);

        if ($fingerprint === null) {
            throw new Crypt_GPG_KeyNotFoundException(
                'Key not found: ' . $keyId,
                self::ERROR_KEY_NOT_FOUND,
                $keyId
            );
        }

        $keyData   = '';
        $operation = $private ? '--export-secret-keys' : '--export';
        $operation .= ' ' . escapeshellarg($fingerprint);
        $arguments = $armor ? array('--armor') : array();

        $this->engine->reset();
        $this->engine->setPins($this->passphrases);
        $this->engine->setOutput($keyData);
        $this->engine->setOperation($operation, $arguments);
        $this->engine->run();

        return $keyData;
    }
protected function _exportKey($keyId, $armor = true, $private = false)
    {
        $fingerprint = $this->getFingerprint($keyId);

        if ($fingerprint === null) {
            throw new Crypt_GPG_KeyNotFoundException(
                'Key not found: ' . $keyId,
                self::ERROR_KEY_NOT_FOUND,
                $keyId
            );
        }

        $keyData   = '';
        $operation = $private ? '--export-secret-keys' : '--export';
        $operation .= ' ' . escapeshellarg($fingerprint);
        $arguments = $armor ? array('--armor') : array();

        $this->engine->reset();
        $this->engine->setPins($this->passphrases);
        $this->engine->setOutput($keyData);
        $this->engine->setOperation($operation, $arguments);
        $this->engine->run();

        return $keyData;
    }
Exports a private or public key from the keyring

If more than one key fingerprint is available for the specified
<kbd>$keyId</kbd> (for example, if you use a non-unique uid) only the
first key is exported.

@param string  $keyId   either the full uid of the key, the email
part of the uid of the key or the key id.
@param boolean $armor   optional. If true, ASCII armored data is returned;
otherwise, binary data is returned. Defaults to
true.
@param boolean $private return private instead of public key

@return string the key data.

@throws Crypt_GPG_KeyNotFoundException if a key with the given
<kbd>$keyId</kbd> is not found.

@throws Crypt_GPG_BadPassphraseException if a required passphrase is
incorrect or if a required passphrase is not specified. See
{@link Crypt_GPG::addPassphrase()}.

@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.