- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<?php
$res = gnupg_init();
gnupg_clearsignkeys($res);
$key = get_pub_key();// Value pasted below
$publicImp = gnupg_import($res, $key);
gnupg_addsignkey($res, $publicImp['fingerprint']);
echo gnupg_geterror($res); // Prints `get_key failed`
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: BCPG C# v1.6.1.0
mQENBF3FXV0BCACy/cvfn5oEZQG+Wz8803XvpHVP0NWwIDAuogOsSfDIZX3xBK4s
Ul8y/aXkhPeK4V+NwurNiGqWQXCg3tKX77pfFGo0iBwDQlACmNhxtga/bkDOROx+
O5Ete2olKJ0qVDJTIpA1XMTZK+dFor8oKDWGlYyZ7w1mVxit65fkmzxIdCKrKxGw
9KqHZDkzCwRlpyZ/cQYVPNrx+9GREal2b+XLN3Y9Lbx2OD5FTxO6tLee2XlQdaXJ
R/hetUnei0hoP3J1Zdp99Qh+SX7cGZ+jUcGSdrDEx8q066Q7473xVDJ3Lr0YG53K
EW3lA5z13IkMFn4Yn6taJgkyF/QJtMDZ0xlTABEBAAG0DEhpQGdtYWlsLmNvbYkB
HAQQAQIABgUCXcVdXQAKCRBYbc/NUpqITuYOB/9br/Oc2ahZrbE/GOUOWQc3Yp26
rE+gcp5OjX0WXHsqfxRpVgIb7Si0hr5PPPiCiahS7n44IfZ0CGFcenhv+Eb93h5t
UtC26LRfv1ACTF7tX0QZAeACvB/npB0MMTO/dlbl6eIBjCKHmGMBMBW8WHG39J0V
m5X4GwX6vdTPWQH5ZbpNQirvhLTdYBw6JGtkU++K1gW9kZcncV+3EsRnHIqF5B1G
LnGBYOm9bAdCz2b6J8dkPqjCA9Uw5mvBI5ikB0NruZH8kXynzibnwTpXTc+N3Dsl
5dlRVPh7bIIpGdOVKWqtdnLpNDiY/dQhhmNJ64ZkXOnMibx0qPNYmy3iIgN/
=pvzn
-----END PGP PUBLIC KEY BLOCK-----
[fingerprint] => AF4A061F20FFFE141AA366FE586DCFCD529A884E
[keyid] => 586DCFCD529A884E
[timestamp] => 1573215581
[expires] => 0
[is_secret] =>
[invalid] =>
[can_encrypt] => 1
[can_sign] => 1
[disabled] =>
[expired] =>
[revoked] =>
最佳答案
为了使其工作,您还需要导入私钥。
根据 https://www.gnupg.org/gph/en/manual/c235.html :
Key Integrity
When you distribute your public key, you are distributing the public components of your master and subordinate keys as well as the user IDs. Distributing this material alone, however, is a security risk since it is possible for an attacker to tamper with the key. The public key can be modified by adding or substituting keys, or by adding or changing user IDs. By tampering with a user ID, the attacker could change the user ID's email address to have email redirected to himself. By changing one of the encryption keys, the attacker would also be able to decrypt the messages redirected to him.
Using digital signatures is a solution to this problem. When data is signed by a private key, the corresponding public key is bound to the signed data. In other words, only the corresponding public key can be used to verify the signature and ensure that the data has not been modified. A public key can be protected from tampering by using its corresponding private master key to sign the public key components and user IDs, thus binding the components to the public master key. Signing public key components with the corresponding private master signing key is called self-signing, and a public key that has self-signed user IDs bound to it is called a certificate.
<?php
$res = gnupg_init();
gnupg_clearsignkeys($res);
$publicKey = file_get_contents('public.key');
$privateKey = file_get_contents('private.key');
$publicImp = gnupg_import($res, $publicKey);
$privateImp = gnupg_import($res, $privateKey);
gnupg_addsignkey($res, $publicImp['fingerprint']);
echo gnupg_geterror($res);
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: BCPG C# v1.6.1.0
mQENBF3TmV4BCACOy5NyL9OMpCR2T5JpuRnaIZCiQ4dyuEx5HikChBBOo6ttB9Pp
whM8kdZf2Xd7bF9SBX5ZEESNCx1aVvo5pKEh/ziRbx4OQINmVyKfhoG7OIWiXoSI
S8swRISmRteIsARPKn7yJfoxmrlCXwAURDOBfFYbmWDdKmeVSz/AS/tysqmPg12D
WJ7Z4NlNDy2Z0g3yS39xIbqi/tf23NmfCZ9O7dNgdpmIfAO+iZKxz9b/+d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WM2SCiKJyw4Rddu1gRPobqhrRK4aIW9Msn/UN
Ft0Eg4xy9PsB1jiL9CkMkaWKDUv8EoMYtjgN1JzrQWA= =BpXt
-----END PGP PRIVATE KEY BLOCK-----
关于PHP gnupg_addsignkey 错误 : get_key failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58767578/
我正在尝试使用 PHP 中的 PGP(gnupg) 解密一条简单消息。但我总是收到此错误:get_key failed。在 stack-overflow 上,我看到很多人遇到这个问题,但我无法解决。我
AF4A061F20FFFE141AA366FE586DCFCD529A884E [keyid] => 586DCFCD529A884E [timestamp] => 1573215581 [exp
我在 php 中使用 gnupg 作为数字签名文件。之前工作正常。突然我收到这个错误: PHP Fatal error: Uncaught exception 'Exception' with mes
我想将 PGP 加密集成到我的 Web 应用程序中,在寻找要使用的内容(扩展、库等)之后,我决定使用 php 的 gnupg 扩展。现在,我的一个桌面文件夹中确实有一个 PGP key ,我尝试将它的
我是一名优秀的程序员,十分优秀!