File: encoding.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 (32 lines) | stat: -rw-r--r-- 571 bytes parent folder | download | duplicates (3)
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
30
31
32
package crypto

import (
	"io"

	armorHelper "github.com/ProtonMail/gopenpgp/v3/armor"
)

type PGPEncoding int8

// PGPEncoding determines the message encoding.
// The type is int8 for compatibility with gomobile.
const (
	Armor int8 = 0
	Bytes int8 = 1 // Default for other int8 values.
	Auto  int8 = 2
)

func armorOutput(e int8) bool {
	return e == Armor
}

func unarmorInput(e int8, input io.Reader) (reader Reader, unarmor bool) {
	reader = input
	switch e {
	case Armor:
		unarmor = true
	case Auto:
		reader, unarmor = armorHelper.IsPGPArmored(input)
	}
	return
}