MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / EncodeArmor

Function EncodeArmor

crypto/armor/armor.go:11–26  ·  view source on GitHub ↗
(blockType string, headers map[string]string, data []byte)

Source from the content-addressed store, hash-verified

9)
10
11func 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
28func DecodeArmor(armorStr string) (blockType string, headers map[string]string, data []byte, err error) {
29 buf := bytes.NewBufferString(armorStr)

Callers 1

TestArmorFunction · 0.85

Calls 4

WriteMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.65
EncodeMethod · 0.45

Tested by 1

TestArmorFunction · 0.68