Hướng dẫn dùng gpg sign trong PHP

Xem URL này, nó rất hữu ích cho bạn. Tải xuống ví dụ và thử nó.

https://github.com/singpolyma/openpgp-php

Hoặc Hãy thử nó: -

Bạn có thể tải xuống các tệp lib / openpgp.phplib / openpgp_crypt_rsa.php ở phía trên URL.

ví dụ / keygen.php

createKey(512);
$rsa->loadKey($k['privatekey']);

$nkey = new OpenPGP_SecretKeyPacket(array(
   'n' => $rsa->modulus->toBytes(),
   'e' => $rsa->publicExponent->toBytes(),
   'd' => $rsa->exponent->toBytes(),
   'p' => $rsa->primes[1]->toBytes(),
   'q' => $rsa->primes[2]->toBytes(),
   'u' => $rsa->coefficients[2]->toBytes()
));

$uid = new OpenPGP_UserIDPacket('Test <>');

$wkey = new OpenPGP_Crypt_RSA($nkey);
$m = $wkey->sign_key_userid(array($nkey, $uid));

print $m->to_bytes();

example / sign.php

 'u', 'filename' => 'stuff.txt'));

/* Create a signer from the key */
$sign = new OpenPGP_Crypt_RSA($wkey);

/* The message is the signed data packet */
$m = $sign->sign($data);

/* Output the raw message bytes to STDOUT */
echo $m->to_bytes();

?>

example / verify.php

verify($m));

?>

16 hữu ích 5 bình luận chia sẻ