gnupg_init

(PECL gnupg >= 0.4)

gnupg_init接続を初期化する

説明

gnupg_init(): resource

パラメータ

この関数にはパラメータはありません。

返り値

GnuPG 接続リソースを返します。これを他の GnuPG 関数で使用します。

例1 手続き型の gnupg_init() の例

<?php
$res 
gnupg_init();
?>

例2 オブジェクト指向の gnupg の初期化の例

<?php
$gpg 
= new gnupg();
?>

add a note add a note

User Contributed Notes 1 note

up
4
der_axel at gmx dot de
6 years ago
Set the correct GNUPG environment, before you call gnupg_init()!

The current FPM/FastCGI/Module User must have read - if you import write - permissions on that directory. You won't get an error message, if something is not correct.
Without a correct environment, all other gnupg functions will not work as you expected.

<?php
// Enter your .gnupg environment
putenv('GNUPGHOME=/var/www/vhosts/yourdomain/.gnupg');
error_reporting(E_ALL);
$res = gnupg_init();
gnupg_seterrormode($res,GNUPG_ERROR_WARNING);
$info = gnupg_keyinfo($res, 'your-key-id');
echo
"Key - Info<pre>";
var_dump($info);
echo
"</pre>";
?>
To Top