File: armor.go

package info (click to toggle)
golang-github-protonmail-gopenpgp-v3 3.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,028 kB
  • sloc: sh: 87; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 624 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package internal

import (
	"bytes"
	"fmt"
	"strings"

	"github.com/ProtonMail/go-crypto/openpgp/armor"
)

// Unarmor unarmors an armored string.
func Unarmor(input string) (*armor.Block, error) {
	io := strings.NewReader(input)
	b, err := armor.Decode(io)
	if err != nil {
		return nil, fmt.Errorf("gopenpgp: unable to unarmor: %w", err)
	}
	return b, nil
}

// UnarmorBytes unarmors an armored byte slice.
func UnarmorBytes(input []byte) (*armor.Block, error) {
	io := bytes.NewReader(input)
	b, err := armor.Decode(io)
	if err != nil {
		return nil, fmt.Errorf("gopenpgp: unable to unarmor: %w", err)
	}
	return b, nil
}