T

PEAR: Crypt_GPG

PEARにCrypt_GPGが追加されている。

でもまだ動かない…

動いた!

$ gpg --list-keys yagi@selfkleptomaniac.org
pub   1024D/DB656EDE 2008-01-16
uid                  八木の野郎 (yagi) <yagi@selfkleptomaniac.org>
sub   2048g/FF673BA1 2008-01-16

$ cat gpg.php
<?php

require_once 'Crypt/GPG.php';

$options['homedir'] = $_SERVER['HOME'] . '/.gnupg';
$gpg =& Crypt_GPG::factory('php', $options);
try{
        $obj = $gpg->getKeys();
        print($gpg->getFingerprint('yagi') . "\n");
}catch(Exception $e){
        print("ERROR:\n");
        var_dump($e);
}

try{
        print($gpg->exportPublicKey('yagi') . "\n");
}catch(Exception $e){
        var_dump($e);
        
}
?>

$ php -q gpg.php 
A0E977A2F1C9B803C42E7CDF8C8D56BADB656EDE
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.2.6 (GNU/Linux)

mQGiBEeOEL8RBACye3Xg0mRI+wolkrL2oS17p1j/lAyZIXiX1bsB7EpDPzR2XntW
89k3hNeerJGE3iBi5VNgiIWeNJxOoVCzokeBvRE2yxzRgVxmTwLgLCN/UXJpf2Q1
rjQ5UWvpbBE8nb2I3e4b/sAuLLO51FmP3r0V2FZ7EZH5NtLGhtjbTI6x7wCguP2s
TozncldqdGua6heq8eKHfDsD+wUWkqJ7IDAOoznI5h6JldFy3N7KaJE8L4voaU1y
8Cq/u8toJyz8LbXmQaCf1IAnnvsezZgfaUR+6WP/UBmozQl1sUV486eroPLveWBd
AphBJBvL4s8l0FZor0vMvgc9Ouc8doRoSO55hM8/TmcOfvPqo8agw6RPVBWwft0z
gJyeBACIIDzWqDIV8v5FzucQ1xTgCHTRPjMmwZOv/SbtKrhHU5TcrUvtruhvTgZF
/cmwGTWfu90C93+Sx6+wnUfu4JWzMXsAe6rTIGgdYU6ftqbJIo18LUTw41JjQ8oy
jWk5OXF5w70QQv70HqxhKbZPQL62LY4nE3jOzf9AQ5aeujGt1bQy5YWr5pyo44Gu
6YeO6YOOICh5YWdpKSA8eWFnaUBzZWxma2xlcHRvbWFuaWFjLm9yZz6IXgQTEQIA
HgUCR44QvwIbAwYLCQgHAwIDFQIDAxYCAQIeAQIXgAAKCRCMjVa622Vu3sruAKCy
X5vYH6+I6uTxRKglI/2WDtMTVACeOqgkDGk2bXqCcua+3ucMavIMIvS5Ag0ER44Q
xRAIALvebXwo3pDcOfpnWjiYl7BCJaL8VAToquQLluu1pg24zo5nAaPDxyqLcTgZ
Cqw1odGydP/6gEy8sW/a5b7AmyMZPnvsbhMkM3+FNA0CE7LWeTrvvq9FhhViHBAF
ofRI1SF8k9MlsgBIakms7Ju3OKJC829e5c7Mk+gsoR+YFuenBrTamUe0F2O+fFve
YWHjLJ3T5AK2T2LECxHIQvuineZ549iyJ1kPVgprOuwdoK1thdXPVrfki0ZVzZcx
m/YppaQ3I5e8O8XEcpTeqB7lqV2+krA86Hb95sx/vXy3HprXTVx9dI1QQ14QuWqU
B7rVlrwyfxhbHP4gEiB8JCHjYHsAAwUH/j/gghCcQLFI0w7R1L4PH6DO7eYsv2Ih
7insKDQS7MjoCi2uuIIwI4adrCOW5Vgf/hOwE/b1nK0CRLHtdWNaW86N6+pTXU0S
B8UyJJ0uQ1kZM+6FELZ6wmc8WANIL5MdLbJ7Kcv7ADD+7S9vehYOpv6DRpVDIyUh
0qIyVawdAkPz8jo492/moJlFg9Qxc7T9c+pVM1Ud6uT6ncrtY4hlucj6oVI02pga
pfGhYivDsHcQW09kI2hse506lhZGEHqaA3ZpkGhM0Ys9DdpY5CNMCJwk9Ivk81HH
geLEwT1y0dK181P9ELEwMiCeqtfAdrcbU2iuTBdDJpPPWsFTzlWJF7CISQQYEQIA
CQUCR44QxQIbDAAKCRCMjVa622Vu3v/ZAJ9/8ZrId/uy+g5Q6EHniTzE0MMh0gCg
qSIRP/P3+vgttI9+XzJzIvxy2gM=
=+uLv
-----END PGP PUBLIC KEY BLOCK-----

ちなみにDriverにgnupgを指定できるとあるけど、指定したらエラーになる。うーむ。

Posted by on 1月 16, 2008 in PHP

Comments

  • If this is a bug, please file a bug report in English on the PEAR website. Glad to see you are interested in using this package!

    -Mike

  • admin より:

    Ah, ‘homedir’ is not $_SERVER[‘HOME’] but $_SERVER[‘homedir’] . ‘/.gnupg’ and above example works fine. I’m getting fond of Crypt_GPG, thank you!

  • コメントを残す