gpg

package
v1.1.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// GPGArgs contains the default GPG args for non-interactive use. Note: Do not use '--batch'
	// as this will disable (necessary) passphrase questions!
	GPGArgs = []string{"--quiet", "--yes", "--compress-algo=none", "--no-encrypt-to", "--no-auto-check-trustdb"}
	// Debug prints all the commands executed
	Debug = false
	// GPGBin is the name and possibly location of the gpg binary
	GPGBin = "gpg"
)

Functions

func Decrypt

func Decrypt(path string) ([]byte, error)

Decrypt will try to decrypt the given file

func Encrypt

func Encrypt(path string, content []byte, recipients []string, alwaysTrust bool) error

Encrypt will encrypt the given content for the recipients. If alwaysTrust is true the trust-model will be set to always as to avoid (annoying) "unuseable public key" errors when encrypting.

func ExportPublicKey

func ExportPublicKey(id, filename string) error

ExportPublicKey will export the named public key to the location given

func GetRecipients

func GetRecipients(file string) ([]string, error)

GetRecipients returns a list of recipient IDs for a given file

func ImportPublicKey

func ImportPublicKey(filename string) error

ImportPublicKey will import a key from the given location

Types

type Identity

type Identity struct {
	Name    string
	Comment string
	Email   string
}

Identity is a GPG identity, one key can have many IDs

func (Identity) ID

func (i Identity) ID() string

ID returns the GPG ID format

func (Identity) String

func (i Identity) String() string

String implement fmt.Stringer. This method resembels the output gpg uses for user-ids

type Key

type Key struct {
	KeyType        string
	KeyLength      int
	Validity       string
	CreationDate   time.Time
	ExpirationDate time.Time
	Ownertrust     string
	Fingerprint    string
	Identities     map[string]Identity
	SubKeys        map[string]struct{}
}

Key is a GPG key (public or secret)

func (Key) IsUseable

func (k Key) IsUseable() bool

IsUseable returns true if GPG would assume this key is useable for encryption

func (Key) OneLine

func (k Key) OneLine() string

OneLine prints a terse representation of this key on one line (includes only the first identity!)

func (Key) String

func (k Key) String() string

String implement fmt.Stringer. This method produces output that is close to, but not exactly the same, as the output form GPG itself

type KeyList

type KeyList []Key

KeyList is a searchable slice of Keys

func ListPrivateKeys

func ListPrivateKeys(search ...string) (KeyList, error)

ListPrivateKeys returns a parsed list of GPG secret keys

func ListPublicKeys

func ListPublicKeys(search ...string) (KeyList, error)

ListPublicKeys returns a parsed list of GPG public keys

func ParseColons

func ParseColons(reader io.Reader) KeyList

ParseColons parses the `--with-colons` output format of GPG

func (KeyList) FindKey

func (kl KeyList) FindKey(id string) (Key, error)

FindKey will try to find the requested key

func (KeyList) UseableKeys

func (kl KeyList) UseableKeys() KeyList

UseableKeys returns the list of useable (valid keys)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL