Crypt/GPG.php
protected function _sign($data, $isFile, $outputFile, $mode, $armor,
        $textmode
    ) {
        if (!$this->hasSignKeys()) {
            throw new Crypt_GPG_KeyNotFoundException(
                'No signing keys specified.'
            );
        }

        $input  = $this->_prepareInput($data, $isFile);
        $output = $this->_prepareOutput($outputFile, $input);

        switch ($mode) {
        case self::SIGN_MODE_DETACHED:
            $operation = '--detach-sign';
            break;
        case self::SIGN_MODE_CLEAR:
            $operation = '--clearsign';
            break;
        case self::SIGN_MODE_NORMAL:
        default:
            $operation = '--sign';
            break;
        }

        $arguments = array();

        if ($armor) {
            $arguments[] = '--armor';
        }
        if ($textmode) {
            $arguments[] = '--textmode';
        }

        foreach ($this->signKeys as $key) {
            $arguments[] = '--local-user ' .
                escapeshellarg($key['fingerprint']);
        }

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

        if ($outputFile === null) {
            return $output;
        }
    }
protected function _sign($data, $isFile, $outputFile, $mode, $armor,
        $textmode
    ) {
        if (!$this->hasSignKeys()) {
            throw new Crypt_GPG_KeyNotFoundException(
                'No signing keys specified.'
            );
        }

        $input  = $this->_prepareInput($data, $isFile);
        $output = $this->_prepareOutput($outputFile, $input);

        switch ($mode) {
        case self::SIGN_MODE_DETACHED:
            $operation = '--detach-sign';
            break;
        case self::SIGN_MODE_CLEAR:
            $operation = '--clearsign';
            break;
        case self::SIGN_MODE_NORMAL:
        default:
            $operation = '--sign';
            break;
        }

        $arguments = array();

        if ($armor) {
            $arguments[] = '--armor';
        }
        if ($textmode) {
            $arguments[] = '--textmode';
        }

        foreach ($this->signKeys as $key) {
            $arguments[] = '--local-user ' .
                escapeshellarg($key['fingerprint']);
        }

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

        if ($outputFile === null) {
            return $output;
        }
    }
Signs data

@param string  $data       the data to be signed.
@param boolean $isFile     whether or not the data is a filename.
@param string  $outputFile the name of the file in which the signed data
should be stored. If null, the signed data is
returned as a string.
@param int     $mode       the data signing mode to use. Should be one of
{@link Crypt_GPG::SIGN_MODE_NORMAL},
{@link Crypt_GPG::SIGN_MODE_CLEAR} or
{@link Crypt_GPG::SIGN_MODE_DETACHED}.
@param boolean $armor      if true, ASCII armored data is returned;
otherwise, binary data is returned. This has
no effect if the mode
<kbd>Crypt_GPG::SIGN_MODE_CLEAR</kbd> is
used.
@param boolean $textmode   if true, line-breaks in signed data be
normalized. Use this option when signing
e-mail, or for greater compatibility between
systems with different line-break formats.
Defaults to false. This has no effect if the
mode <kbd>Crypt_GPG::SIGN_MODE_CLEAR</kbd> is
used as clear-signing always uses textmode.

@return void|string if the <kbd>$outputFile</kbd> parameter is null, a
string containing the signed data (or the signature
data if a detached signature is requested) is
returned.

@throws Crypt_GPG_KeyNotFoundException if no signing key is specified.
See {@link Crypt_GPG::addSignKey()}.

@throws Crypt_GPG_BadPassphraseException if a specified passphrase is
incorrect or if a required passphrase is not specified.

@throws Crypt_GPG_FileException if the output file is not writeable or
if the input file is not readable.

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