PHP: gnupg Функции - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

gnupg_adddecryptkey gmp_xor

Last updated: Sat, 27 Jan 2007

view this page in

# LI. gnupg Функции

# Введение

This module allows you to interact with gnupg.

Внимание
Это расширение является ЭКСПЕРИМЕНТАЛЬНЫМ. Поведение этого расширения, включая имена его функций и относящуюся к нему документацию, может измениться в последующих версиях PHP без уведомления. Используйте это расширение на свой страх и риск.

# Требования

The gnupg extension requires PHP 4.3. To use this extension in an OO style, PHP 5 is required.

This extension requires the gpgme library

# Установка

The gnupg-extension is not bundled with PHP. It is a PECL extension and can be located here: http://pecl.php.net/package/gnupg.

# Предопределенные константы

`GNUPG_SIG_MODE_NORMAL` (integer)

`GNUPG_SIG_MODE_DETACH` (integer)

`GNUPG_SIG_MODE_CLEAR` (integer)

`GNUPG_VALIDITY_UNKNOWN` (integer)

`GNUPG_VALIDITY_UNDEFINED` (integer)

`GNUPG_VALIDITY_NEVER` (integer)

`GNUPG_VALIDITY_MARGINAL` (integer)

`GNUPG_VALIDITY_FULL` (integer)

`GNUPG_VALIDITY_ULTIMATE` (integer)

`GNUPG_PROTOCOL_OpenPGP` (integer)

`GNUPG_PROTOCOL_CMS` (integer)

`GNUPG_SIGSUM_VALID` (integer)

`GNUPG_SIGSUM_GREEN` (integer)

`GNUPG_SIGSUM_RED` (integer)

`GNUPG_SIGSUM_KEY_REVOKED` (integer)

`GNUPG_SIGSUM_KEY_EXPIRED` (integer)

`GNUPG_SIGSUM_KEY_MISSING` (integer)

`GNUPG_SIGSUM_SIG_EXPIRED` (integer)

`GNUPG_SIGSUM_CRL_MISSING` (integer)

`GNUPG_SIGSUM_CRL_TOO_OLD` (integer)

`GNUPG_SIGSUM_BAD_POLICY` (integer)

`GNUPG_SIGSUM_SYS_ERROR` (integer)

`GNUPG_ERROR_WARNING` (integer)

`GNUPG_ERROR_EXCEPTION` (integer)

`GNUPG_ERROR_SILENT` (integer)

# Примечания

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 putenv for more information how to do this.

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.

# keylistiterator

This extension also comes with an Iterator for your keyring.

`<?php
// create a new iterator for listing all public keys that matches 'example'
$iterator = new gnupg_keylistiterator("example");
foreach($iterator as $fingerprint => $userid){
echo $fingerprint." -> ".$userid."\n";
}
?>`

# Примеры

This example will clearsign a given text.

Пример 1. gnupg clearsign example (procedural)

`<?php
// init gnupg
$res = gnupg_init();
// not really needed. Clearsign is default
gnupg_setsignmode($res,GNUPG_SIG_MODE_CLEAR);
// add key with passphrase 'test' for signing
gnupg_addsignkey($res,"8660281B6051D071D94B5B230549F9DC851566DC","test");
// sign
$signed = gnupg_sign("just a test");
echo $signed;
?>`

Пример 2. gnupg clearsign example (OO)

`<?php
// new class
$gnupg = new gnupg();
// not really needed. Clearsign is default
$gnupg->setsignmode(gnupg::SIG_MODE_CLEAR);
// add key with passphrase 'test' for signing
$gnupg->addsignkey("8660281B6051D071D94B5B230549F9DC851566DC","test");
// sign
$signed = $gnupg->sign("just a test");
echo $signed;
?>`

add a note User Contributed Notes
gnupg Функции
phplist2REMOVE AT REMtincanOVE.co.uk
13-Dec-2006 09:04
`sorry, correction, should read of course:
gnupg_deletekey -- Delete a key`
phplist2REMOVE AT REMtincanOVE.co.uk
08-Nov-2006 09:20
`There's a function/method missing in the list.
gnupg_deletekey
(no version information, might be only in CVS)
gnupg_deletekey -- Signs a given text
Description
bool gnupg_deletekey ( resource identifier, string key, [bool allowsecret] )
Deletes the key from the keyring. If allowsecret is not set or FALSE it will fail on deleting secret keys.
Return Values
On success, this function returns TRUE. On failure, this function returns FALSE.
Examples
Example 1. Procedural gnupg_deletekey() example
<?php
$res = gnupg_init();
gnupg_deletekey($res,"8660281B6051D071D94B5B230549F9DC851566DC");
?>
Example 2. OO gnupg_deletekey() example
<?php
$gpg = new gnupg();
$gpg -> deletekey("8660281B6051D071D94B5B230549F9DC851566DC");
?>`
add a note
gnupg_adddecryptkey gmp_xor

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST