Verify digital signature using php

我与影子孤独终老i 提交于 2019-12-06 19:52:27

PHP already brings a module for interfacing GnuPG, which is fairly easy to use.

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.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!