CakeFest 2024: The Official CakePHP Conference

gnupg_encryptsign

(PECL gnupg >= 0.2)

gnupg_encryptsignEncripta y firma un texto dado

Descripción

gnupg_encryptsign(resource $identifier, string $plaintext): string

Encripta y firma el parámetro plaintext con las llaves que se an indicado anteriormente mediante gnupg_addsignkey y gnupg_addencryptkey y retorna el texto encriptado y firmado.

Parámetros

identifier

El identificador gnupg, desde una llamada a gnupg_init() o gnupg.

plaintext

El texto a ser encriptado.

Valores devueltos

En caso de éxito, esta función retorna el texto encriptado y firmado. En caso de fallo, esta función retorna false.

Ejemplos

Ejemplo #1 Ejemplo de gnupg_encryptsign() mediante funciones

<?php
$res
= gnupg_init();
gnupg_addencryptkey($res,"8660281B6051D071D94B5B230549F9DC851566DC");
gnupg_addsignkey($res,"8660281B6051D071D94B5B230549F9DC851566DC","test");
$enc = gnupg_encryptsign($res, "just a test");
echo
$enc;
?>

Ejemplo #2 Ejemplo de gnupg_encryptsign() mediante OO

<?php
$gpg
= new gnupg();
$gpg -> addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");
$gpg -> addsignkey("8660281B6051D071D94B5B230549F9DC851566DC","test");
$enc = $gpg -> encryptsign("just a test");
echo
$enc;
?>

add a note

User Contributed Notes 1 note

up
0
upul at tfs dot co
6 months ago
$gpg->addencryptkey('Sender public key fingerprint ');
$gpg->addsignkey('My Private key fingerprint',$passphrase);
$enc = $gpg->encryptsign(test.csv);

With the above code file gets encrypted but the file does not get signed. moreover, if I use my public key fingerprint for addencryptkey file gets encrypted and signed. Any idea for this issue?
To Top