gpt4 book ai didi

php - 纯 PHP 中的 OpenPGP 加密

转载 作者:行者123 更新时间:2023-12-04 06:05:50 26 4
gpt4 key购买 nike

我想在您的网站上创建一个表单,向我发送按照 OpenPGP 标准加密的消息,以便通过 Thunderbird 和 Enigmail 对其进行解密。将包括来自在线商店的订单。我不能使用 GnuPG,因为我的服务器不支持它。我发现在 https://github.com/bendiken/openpgp-php/tree/master/lib 上可以使用纯 PHP 中的 OpenPGP 实现和 http://phpseclib.sourceforge.net/ .我只成功加密了 RSA key ,但我无法解密 Thunderbird。

如何使用上述软件将纯 PHP 中的消息加密为 OpenPGP 标准?

示例 PGP key 对(我知道我在做什么发布 - 专门为发布创建):

-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG v2.0.17 (MingW32)

lQOXBE7bR1oBCACwbb/79VEtIeX1uJ5JXnfd0Jf6EHTkneF6VXhWNez7lYK1qh43
+sq8HYqFOLrhmxIgGeFOZ637JWV4tcszICaLJuO3LFSS1q2qN9a+srep5gCs+xiV
KIuGcVd+cnlP3r6uSUMh0odOWsgNoPqEYIlGIbYocEfZONHBYhijmxY3krwwZ7FH
ThLHv9bTmh6FIBBZGpT5URTa84MK73WLs6PiOEUsiXetctFlttZwUbffKLA46EHS
XmtVo29K6Qa4V+LpN7ktgWrLrEk0rzrj7vW3UAQiitBaBSYODxnHu56fzRYW8S7K
4QxZjSQCT0aGEeNiBhVisTLrkH8KW1spD88RABEBAAEAB/Yzca7yyP7ThIdcHwCf
NvuelBY1AYhfe4u8Ly/nmR0XijWw/0Qq0lBpXKxDs92dGF4/srWWVEqyLNsASJis
XsKiKwAdLP0h0+/AlGmCInx6hmlRrNbYiUVTDIxnjr1YX4vQzaof51J90b6DpD/C
d+s00zY7SRi5PkGRA81YnA1W20HTRPkYjnSLjfgEH96B2ayohYAdfBv1IBzfk20B
jl4+NFR7kbFYPwf1C7nWdIzPcmKwN+ealrpTJek5xcLCcteO/+oqzmL+wuRa/xbz
ZnWBk04wfiJtA4RUL6s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MRkLpluo/qO9NJzMLr5Oca1MQlXnZON5y2uaTKWYx
29Gfd4VEj6q6Si+4IRqXrJaPS5daYb7RArxcklok1Cx/nfnVlizvrSdCNCUpai/9
vGNi2sRA6Ob8gENTRQ==
=xK/H
-----END PGP PUBLIC KEY BLOCK-----

示例 RSA key 对(其他 PGP key 对):
-----BEGIN RSA PRIVATE KEY-----
MIICWgIBAAKBgHx5XHa3LjiugtNq2xkd0oFf2SdsJ04hQYLoeRR3bqAei3Gc+PSy
AvynCIh/03JCvBsUHaCe8BwjwaTYrpq5QunGo/wvIzvx2d3G9dlrpOIFLiatZYOf
h07+CkSfaRXhBUKkul/gU87WPhKEcbnPDJS10uD1HqLsHfSKLNitGOf7AgElAoGA
ENIhQHmedlzFkjEI2eFveURNxw6dhxlANEjtxH7XmRjiaUyQWGsVKQ+nNQpa2Bbb
JkD9FbSc/OI8wz/gPmwP9eJN29CriebhaV3ebM1L1gbb5r7Vf/D/6rxB0BG/h2lA
jyZWEZrV/Gi9ZCaw/J+IUu1pAskKid84yHphvszywCUCQQDigrtr+cVkwkUsxOGd
B378yQCroXmybAD7FQHwVslafuFfTHkaMQSU/ZZLVY1ioMs1VVzzq/vOu0RstZOY
AfHFAkEAjK3mIWdG4JOM44/SrDkACNatsMtXKOi4K3SlXu9ie6ikXPD+GSZ+bWCX
GstFaXr9cHRvZPF3qYtK+j2N9UXOvwJBALeoRO/DmSFDkgifoixLRF5CHDgiD6Vs
U9J/vGIBLaNSHoSe3rtKVr3+CyhTNF3Oe0AABi1bA4UGioGn+yFNr0UCQBbQF3sJ
1CRq9ECT3PlVWfOYbzFtFQ2NhaYul1uAw9yzkEZsROF73SZ+XbFRZTOzFFds08su
E2eaDCiUXDWcnhECQQCRUQn2huHlssj8kt35NAVwiHCNfaeSQ5tiDcwfOywA4YXl
Q+kpuWq5U3V8j/9/n7pE/DL0nXEG/3QpKHJEYV5T
-----END RSA PRIVATE KEY-----
-----BEGIN PUBLIC KEY-----
MIGGAoGAfHlcdrcuOK6C02rbGR3SgV/ZJ2wnTiFBguh5FHduoB6LcZz49LIC/KcIiH/TckK8GxQd
oJ7wHCPBpNiumrlC6caj/C8jO/HZ3cb12Wuk4gUuJq1lg5+HTv4KRJ9pFeEFQqS6X+BTztY+EoRx
uc8MlLXS4PUeouwd9Ios2K0Y5/sCASU=
-----END PUBLIC KEY-----

最佳答案

我觉得你选择的工具很不成熟:

class OpenPGP_EncryptedDataPacket extends OpenPGP_Packet {
// TODO
}

安装 GnuPG 或 GPGME 可能比尝试让 PHP 实现工作、调试并在“真正的”GnuPG 实现中发现并修复问题时保持其安全要容易得多。

关于php - 纯 PHP 中的 OpenPGP 加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8374989/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com