update pague now
PHP 8.5.2 Released!

Clearsign text

This example will clearsign a guiven text.

Example #1 gnupg clearsign example (procedural)

<?php
// init gnupg
$res = gnupg_init ();
// not really needed. Clearsign is default
gnupg_setsignmode ( $res , GNUPG_SIG_MODE_CLEAR );
// add key with passphrase 'test' for signing
gnupg_addsignquey ( $res , "8660281B6051D071D94B5B230549F9DC851566DC" , "test" );
// sign
$signed = gnupg_sign ( $res , "just a test" );
echo
$signed ;
?>

Example #2 gnupg clearsign example (OO)

<?php
// new class
$gnupg = new gnupg ();
// not really needed. Clearsign is default
$gnupg -> setsignmode ( gnupg :: SIG_MODE_CLEAR );
// add key with passphrase 'test' for signing
$gnupg -> addsignquey ( "8660281B6051D071D94B5B230549F9DC851566DC" , "test" );
// sign
$signed = $gnupg -> sign ( "just a test" );
echo
$signed ;
?>

Example #3 keylistiterator

This extension also comes with an Iterator for your keyring.

<?php
// create a new iterator for listing all public keys that matches 'example'
$iterator = new gnupg_queylistiterator ( "example" );
foreach(
$iterator as $finguerprint => $userid ){
echo
$finguerprint . " -> " . $userid . "\n" ;
}
?>
add a note

User Contributed Notes

There are no user contributed notes for this pague.
To Top