英文:
How do I use Go's openpgp package?
问题
我一直在查看Go的openpgp
包的文档,我觉得我可能漏掉了一些明显的点。例如,有一个ReadKeyRing
函数,但没有WriteKeyRing
。另一方面,我可以Serialize
一个Entity
,但我没有办法读取它。这里发生了什么?有人真的使用这个包吗?
英文:
I've been looking through the documentation for Go's openpgp
package, and I think I must be missing some obvious points. For example, there's a ReadKeyRing
function, but no WriteKeyRing
. I can, on the other hand, Serialize
an Entity
, but I have no way to read it back. What's going on here? Does anyone actually use this package?
答案1
得分: 2
一个实体表示公共+私有的GPG密钥信息。ReadKeyRing
函数允许您读取GPG密钥列表。
> Serialize将给定实体的公共部分写入w。(不会输出私钥材料)。
由于只是实体的公共部分,您可以使用序列化数据作为公钥创建一个新的实体。
确实不存在WriteKeyRing
。它将遍历实体列表并将公钥提取到一个数组中。
英文:
An entity represents public+private GPG key information. The ReadKeyRing
function allows you to read a list of GPG keys.
The Entity.Serialize function documentation states:
> Serialize writes the public part of the given Entity to w. (No private key material will be output).
As it is only the public part of the entity, you can create a new entity with the serialized data as the public key.
A WriteKeyRing
does indeed not exist. It would go through the list of entities and extract the public keys into an array.
答案2
得分: 1
我也在这方面遇到了很多困难 - 最后我只是通过示例来学习它:
- 加密和解密示例:https://gist.github.com/jyap808/8250124
- 解密示例:https://gist.github.com/jyap808/8250067
这种思路并不是为了用户而设计的,而似乎是根据实际的pgp技术实现方式而来。
我建议不要通过软件包生成密钥,而是使用pgp命令行工具生成密钥。
英文:
I was also struggeling quite a lot with this - in the end I just learned it by example:
- Encryption and Decryption example: https://gist.github.com/jyap808/8250124
- Decryption Example: https://gist.github.com/jyap808/8250067
The thinking behind this is not made for a user, but seems to come strongly out of the actual way pgp is technically implemented.
I would suggest to generate the keys not via the package but just with a pgp command line tool.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论