| 124 | var newlineBytes = []byte("\n") |
| 125 | |
| 126 | func ArmoredPublicKey(entity *openpgp.Entity) (string, error) { |
| 127 | var buf bytes.Buffer |
| 128 | wc, err := armor.Encode(&buf, openpgp.PublicKeyType, nil) |
| 129 | if err != nil { |
| 130 | return "", err |
| 131 | } |
| 132 | err = entity.PrivateKey.PublicKey.Serialize(wc) |
| 133 | if err != nil { |
| 134 | return "", err |
| 135 | } |
| 136 | wc.Close() |
| 137 | if !bytes.HasSuffix(buf.Bytes(), newlineBytes) { |
| 138 | buf.WriteString("\n") |
| 139 | } |
| 140 | return buf.String(), nil |
| 141 | } |
| 142 | |
| 143 | // NewEntity returns a new OpenPGP entity. |
| 144 | func NewEntity() (*openpgp.Entity, error) { |