如何使用Go的openpgp包?

huangapple go评论94阅读模式
英文:

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密钥列表。

Entity.Serialize函数文档中说明:

> 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:

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.

huangapple
  • 本文由 发表于 2011年10月15日 09:28:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/7775181.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定