Example #1
0
 /**
  * Sign the chunk provided as with the specified key
  *
  * @param $data The data as a string blob
  * @param $keyfp The key fingerprint
  * @return The signature
  */
 static function sign($keyfp)
 {
     $gp = gnupg_init();
     gnupg_addsignkey($gp, $keyfb);
     gnupg_setsignmode($gp, GNUPG_SIG_MODE_DETACH);
     $signature = gnupg_sign($gp, $this->data);
     return $signature;
 }
Example #2
0
<?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_addsignkey($res, "8660281B6051D071D94B5B230549F9DC851566DC", "test");
// sign
$signed = gnupg_sign($res, "just a test");
echo $signed;