As of gnupg version 2, it is not possible to pass a plain password any more. The parameter is simply ignored. Instead, a pinentry application will be launched in case of php running in cli mode. In cgi or apache mode, opening the key will fail.
The simplest solution is to use keys without passwords.
gnupg_decrypt
(PECL gnupg >= 0.1)
gnupg_decrypt — Déchiffre un texte donné
Description
string gnupg_decrypt
( resource
$identifier
, string $text
)Déchiffre un texte donné avec les clés qui ont été fixées avec gnupg_adddecryptkey auparavant.
Liste de paramètres
-
identifier -
L'identifiant gnupg, généré par un appel à la fonction gnupg_init() ou à la fonction gnupg.
-
text -
Le texte à déchiffrer.
Valeurs de retour
Cette fonction retourne TRUE en cas de
succès ou FALSE si une erreur survient.
Exemples
Exemple #1 Exemple avec gnupg_decrypt() (Style procédural)
<?php
$res = gnupg_init();
gnupg_adddecryptkey($res,"8660281B6051D071D94B5B230549F9DC851566DC","test");
$plain = gnupg_decrypt($res,$encrypted_text);
echo $plain;
?>
Exemple #2 Exemple avec gnupg_encrypt() (Style orienté objet)
<?php
$gpg = new gnupg();
$gpg -> adddecryptkey("8660281B6051D071D94B5B230549F9DC851566DC","test");
$plain = $gpg -> decrypt($encrypted_text);
echo $plain;
?>
Mike
28-Jan-2010 03:26
