| 9 | ) |
| 10 | |
| 11 | func EncodeArmor(blockType string, headers map[string]string, data []byte) string { |
| 12 | buf := new(bytes.Buffer) |
| 13 | w, err := armor.Encode(buf, blockType, headers) |
| 14 | if err != nil { |
| 15 | panic(fmt.Errorf("could not encode ascii armor: %s", err)) |
| 16 | } |
| 17 | _, err = w.Write(data) |
| 18 | if err != nil { |
| 19 | panic(fmt.Errorf("could not encode ascii armor: %s", err)) |
| 20 | } |
| 21 | err = w.Close() |
| 22 | if err != nil { |
| 23 | panic(fmt.Errorf("could not encode ascii armor: %s", err)) |
| 24 | } |
| 25 | return buf.String() |
| 26 | } |
| 27 | |
| 28 | func DecodeArmor(armorStr string) (blockType string, headers map[string]string, data []byte, err error) { |
| 29 | buf := bytes.NewBufferString(armorStr) |