Это расширение является
ЭКСПЕРИМЕНТАЛЬНЫМ. Поведение этого расширения,
включая имена его функций и относящуюся к нему документацию, может
измениться в последующих версиях PHP без уведомления. Используйте
это расширение на свой страх и риск.
This extension makes use of the keyring of the current user. This keyring
is normaly 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.
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"; } ?>
<?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; ?>