更新时间:2023-12-01 12:06:40
PHP already brings a module for interfacing GnuPG, which is fairly easy to use.
GnuPG必须已经安装在Linux服务器上,通常是在Windows机器上,我听说让PHP与GnuPG一起运行非常困难.
GnuPG must already be installed, on Linux servers it usually is, on Windows machines I heard of getting PHP running together with GnuPG rather difficult.
对于验证签名,请使用 gnupg_verify(...)
,来自链接的PHP文档的示例:
For verifying signatures, use gnupg_verify(...)
, example from the linked PHP documentation:
<?php
$plaintext = "";
$gpg = new gnupg();
// clearsigned
$info = $gpg -> verify($signed_text,false,$plaintext);
print_r($info);
// detached signature
$info = $gpg -> verify($signed_text,$signature);
print_r($info);
?>
在验证之前,您必须导入签名者的公钥,如果还没有完成的话.
You will have to import the signer's public key before verifying, if not done already.