Initialize a connection

# gnupg_init

(PECL gnupg >= 0.4)

gnupg_init — Initialize a connection

### 说明

function gnupg_init(?array `$options` = `null`): resource

### 参数

`options`

  Must be an associative array. It is used to change the default configuration of the crypto engine.

  Configuration overrides
  key | type | description
  --- | --- | ---
  file_name | string | It is the file name of the executable program implementing this protocol which is usually path of the `gpg` executable.
  home_dir | string | It is the directory name of the configuration directory. It also overrides `GNUPGHOME` environment variable that is used for the same purpose.

### 返回值

A GnuPG resource connection used by other GnuPG functions.

### 更新日志

版本 | 说明
--- | ---
PECL gnupg 1.5.0 | The `options` parameter was added.

### 示例

示例 #1 Procedural gnupg_init() example with default setting

    <?php
    $res = gnupg_init();
    ?>

示例 #2 Procedural gnupg_init() example with overridden file name and home dir

    <?php
    $res = gnupg_init(["file_name" => "/usr/bin/gpg2", "home_dir" => "/var/www/.gnupg"]);
    ?>

示例 #3 OO gnupg initializer example with default setting

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

示例 #4 OO gnupg initializer example with overridden file name and home dir

    <?php
    $gpg = new gnupg(["file_name" => "/usr/bin/gpg2", "home_dir" => "/var/www/.gnupg"]);
    ?>

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open