gnupg_setarmor

(PECL gnupg >= 0.1)

gnupg_setarmorToggle armored output

说明

gnupg_setarmor ( resource $identifier , int $armor ) : bool

Toggle the armored output.

参数

identifier

gnupg 标识符,由对 gnupg_init()gnupg 的调用生成。

armor

Pass a non-zero integer-value to this function to enable armored-output (default). Pass 0 to disable armored output.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

Example #1 Procedural gnupg_setarmor() example

<?php
$res 
gnupg_init();
gnupg_setarmor($res,1); // enable armored output;
gnupg_setarmor($res,0); // disable armored output;
?>

Example #2 OO gnupg_setarmor() example

<?php
$gpg 
= new gnupg();
$gpg -> setarmor(1); // enable armored output;
$gpg -> setarmor(0); // disable armored output;
?>

User Contributed Notes

jmgorena at gmail dot com 10-Jan-2008 02:51
Take note that when ARMOR is set to OFF, the output will be BINARY. This is wanted for converting file data to a binary gpg format.

With the ARMOR set to ON, the output is ASCII. This might be used for messaging (email, IM, IRC, etc).

Example with Armor on:
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.6 (GNU/Linux)

hQIOA+9JbyriNorZEAf/UuCyC0T80XffXVkmewfrRSvtsYbNSGZFvSr+32jJT2fs
...
...
=YJ4D
-----END PGP MESSAGE-----