Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 12154

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>gnupg 函数</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="函数参考"
HREF="funcref.html"><LINK
REL="PREVIOUS"
TITLE="gmp_xor"
HREF="function.gmp-xor.html"><LINK
REL="NEXT"
TITLE="gnupg_adddecryptkey"
HREF="function.gnupg-adddecryptkey.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="reference"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.gmp-xor.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.gnupg-adddecryptkey.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.gnupg"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>LI. gnupg 函数</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN65147"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gnupg.intro"
>简介</A
></H1
><P
>&#13;    This module allows you to interact with <A
HREF="http://www.gnupg.org/"
TARGET="_top"
>gnupg</A
>.
    <DIV
CLASS="warning"
><P
></P
><TABLE
CLASS="warning"
BORDER="1"
WIDTH="100%"
><TR
><TD
ALIGN="CENTER"
><B
>警告</B
></TD
></TR
><TR
><TD
ALIGN="LEFT"
><P
>本扩展模块是<SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>实验性</I
></SPAN
>的。本模块的行为,包括其函数的名称以及其它任何关于此模块的文档可能会在没有通知的情况下随
PHP 以后的发布而改变。使用本扩展模块风险自担。</P
></TD
></TR
></TABLE
></DIV
>
   </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gnupg.requirements"
>需求</A
></H1
><P
>&#13;    The gnupg extension requires PHP 4.3.
    To use this extension in an OO style, PHP 5 is required.
   </P
><P
>&#13;    This extension requires the <A
HREF="http://www.gnupg.org/(en)/download/index.html#gpgme"
TARGET="_top"
>gpgme
    library</A
>
   </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gnupg.installation"
>安装</A
></H1
><P
>&#13;  The gnupg-extension is not bundled with PHP.  It is a <A
HREF="http://pecl.php.net/"
TARGET="_top"
>PECL</A
> extension and can be located here:
  <A
HREF="http://pecl.php.net/package/gnupg"
TARGET="_top"
>http://pecl.php.net/package/gnupg</A
>.
 </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gnupg.constants"
>预定义常量</A
></H1
><P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIG_MODE_NORMAL</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIG_MODE_DETACH</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIG_MODE_CLEAR</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_VALIDITY_UNKNOWN</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_VALIDITY_UNDEFINED</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_VALIDITY_NEVER</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_VALIDITY_MARGINAL</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_VALIDITY_FULL</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_VALIDITY_ULTIMATE</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_PROTOCOL_OpenPGP</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_PROTOCOL_CMS</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_VALID</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_GREEN</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_RED</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_KEY_REVOKED</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_KEY_EXPIRED</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_KEY_MISSING</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_SIG_EXPIRED</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_CRL_MISSING</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_CRL_TOO_OLD</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_BAD_POLICY</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_SIGSUM_SYS_ERROR</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_ERROR_WARNING</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_ERROR_EXCEPTION</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GNUPG_ERROR_SILENT</B
></TT
>
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;
    </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gnupg.notes"
>注释</A
></H1
><P
>&#13;    This extension makes use of the keyring of the current user. This keyring
    is normally located in ~./.gnupg/.
    To specify a custom location, store the path to the keyring in the
    environment variable GNUPGHOME. See <A
HREF="function.putenv.html"
>putenv</A
> for more information how to do
    this.
   </P
><P
>&#13;    Some functions require the specification of a key. This specification can
    be anything that refers to an unique key (userid, key-id, fingerprint,
    ...).
    This documentation uses the fingerprint in all examples.
   </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gnupg.keylistiterator"
>keylistiterator</A
></H1
><P
>&#13;    This extension also comes with an Iterator for your keyring.
    <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// create a new iterator for listing all public keys that matches 'example'<br /></font><font color="#0000BB">$iterator </font><font color="#007700">= new </font><font color="#0000BB">gnupg_keylistiterator</font><font color="#007700">(</font><font color="#DD0000">"example"</font><font color="#007700">);<br />foreach(</font><font color="#0000BB">$iterator </font><font color="#007700">as </font><font color="#0000BB">$fingerprint </font><font color="#007700">=&gt; </font><font color="#0000BB">$userid</font><font color="#007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#0000BB">$fingerprint</font><font color="#007700">.</font><font color="#DD0000">" -&gt; "</font><font color="#007700">.</font><font color="#0000BB">$userid</font><font color="#007700">.</font><font color="#DD0000">"\n"</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
>  
   </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gnupg.examples"
>范例</A
></H1
><P
>&#13;    This example will clearsign a given text.
   </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN65330"
></A
><P
><B
>例 1. gnupg clearsign example (procedural)</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// init gnupg<br /></font><font color="#0000BB">$res </font><font color="#007700">= </font><font color="#0000BB">gnupg_init</font><font color="#007700">();<br /></font><font color="#FF8000">// not really needed. Clearsign is default<br /></font><font color="#0000BB">gnupg_setsignmode</font><font color="#007700">(</font><font color="#0000BB">$res</font><font color="#007700">,</font><font color="#0000BB">GNUPG_SIG_MODE_CLEAR</font><font color="#007700">);<br /></font><font color="#FF8000">// add key with passphrase 'test' for signing<br /></font><font color="#0000BB">gnupg_addsignkey</font><font color="#007700">(</font><font color="#0000BB">$res</font><font color="#007700">,</font><font color="#DD0000">"8660281B6051D071D94B5B230549F9DC851566DC"</font><font color="#007700">,</font><font color="#DD0000">"test"</font><font color="#007700">);<br /></font><font color="#FF8000">// sign<br /></font><font color="#0000BB">$signed </font><font color="#007700">= </font><font color="#0000BB">gnupg_sign</font><font color="#007700">(</font><font color="#0000BB">$res</font><font color="#007700">,</font><font color="#DD0000">"just a test"</font><font color="#007700">);<br />echo </font><font color="#0000BB">$signed</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN65333"
></A
><P
><B
>例 2. gnupg clearsign example (OO)</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// new class<br /></font><font color="#0000BB">$gnupg </font><font color="#007700">= new </font><font color="#0000BB">gnupg</font><font color="#007700">();<br /></font><font color="#FF8000">// not really needed. Clearsign is default<br /></font><font color="#0000BB">$gnupg</font><font color="#007700">-&gt;</font><font color="#0000BB">setsignmode</font><font color="#007700">(</font><font color="#0000BB">gnupg</font><font color="#007700">::</font><font color="#0000BB">SIG_MODE_CLEAR</font><font color="#007700">);<br /></font><font color="#FF8000">// add key with passphrase 'test' for signing<br /></font><font color="#0000BB">$gnupg</font><font color="#007700">-&gt;</font><font color="#0000BB">addsignkey</font><font color="#007700">(</font><font color="#DD0000">"8660281B6051D071D94B5B230549F9DC851566DC"</font><font color="#007700">,</font><font color="#DD0000">"test"</font><font color="#007700">);<br /></font><font color="#FF8000">// sign<br /></font><font color="#0000BB">$signed </font><font color="#007700">= </font><font color="#0000BB">$gnupg</font><font color="#007700">-&gt;</font><font color="#0000BB">sign</font><font color="#007700">(</font><font color="#DD0000">"just a test"</font><font color="#007700">);<br />echo </font><font color="#0000BB">$signed</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>目录</B
></DT
><DT
><A
HREF="function.gnupg-adddecryptkey.html"
>gnupg_adddecryptkey</A
>&nbsp;--&nbsp;Add a key for decryption</DT
><DT
><A
HREF="function.gnupg-addencryptkey.html"
>gnupg_addencryptkey</A
>&nbsp;--&nbsp;Add a key for encryption</DT
><DT
><A
HREF="function.gnupg-addsignkey.html"
>gnupg_addsignkey</A
>&nbsp;--&nbsp;Add a key for signing</DT
><DT
><A
HREF="function.gnupg-cleardecryptkeys.html"
>gnupg_cleardecryptkeys</A
>&nbsp;--&nbsp;Removes all keys which were set for decryption before</DT
><DT
><A
HREF="function.gnupg-clearencryptkeys.html"
>gnupg_clearencryptkeys</A
>&nbsp;--&nbsp;Removes all keys which were set for encryption before</DT
><DT
><A
HREF="function.gnupg-clearsignkeys.html"
>gnupg_clearsignkeys</A
>&nbsp;--&nbsp;Removes all keys which were set for signing before</DT
><DT
><A
HREF="function.gnupg-decrypt.html"
>gnupg_decrypt</A
>&nbsp;--&nbsp;Decrypts a given text</DT
><DT
><A
HREF="function.gnupg-decryptverify.html"
>gnupg_decryptverify</A
>&nbsp;--&nbsp;Decrypts and verifies a given text</DT
><DT
><A
HREF="function.gnupg-encrypt.html"
>gnupg_encrypt</A
>&nbsp;--&nbsp;Encrypts a given text</DT
><DT
><A
HREF="function.gnupg-encryptsign.html"
>gnupg_encryptsign</A
>&nbsp;--&nbsp;Encrypts and signs a given text</DT
><DT
><A
HREF="function.gnupg-export.html"
>gnupg_export</A
>&nbsp;--&nbsp;Exports a key</DT
><DT
><A
HREF="function.gnupg-geterror.html"
>gnupg_geterror</A
>&nbsp;--&nbsp;Returns the errortext, if a function fails</DT
><DT
><A
HREF="function.gnupg-getprotocol.html"
>gnupg_getprotocol</A
>&nbsp;--&nbsp;Returns the currently active protocol for all operations</DT
><DT
><A
HREF="function.gnupg-import.html"
>gnupg_import</A
>&nbsp;--&nbsp;Imports a key</DT
><DT
><A
HREF="function.gnupg-keyinfo.html"
>gnupg_keyinfo</A
>&nbsp;--&nbsp;Returns an array with information about all keys that matches the given pattern</DT
><DT
><A
HREF="function.gnupg-setarmor.html"
>gnupg_setarmor</A
>&nbsp;--&nbsp;Toggle armored output</DT
><DT
><A
HREF="function.gnupg-seterrormode.html"
>gnupg_seterrormode</A
>&nbsp;--&nbsp;Sets the mode for error_reporting</DT
><DT
><A
HREF="function.gnupg-setsignmode.html"
>gnupg_setsignmode</A
>&nbsp;--&nbsp;Sets the mode for signing</DT
><DT
><A
HREF="function.gnupg-sign.html"
>gnupg_sign</A
>&nbsp;--&nbsp;Signs a given text</DT
><DT
><A
HREF="function.gnupg-verify.html"
>gnupg_verify</A
>&nbsp;--&nbsp;Verifies a signed text</DT
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.gmp-xor.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.gnupg-adddecryptkey.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>gmp_xor</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>gnupg_adddecryptkey</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>