gogpg

package module
v0.0.0-...-7baac72 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2017 License: MIT Imports: 11 Imported by: 3

README

gogpg

GoDoc Coverage

gogpg is a Go-library with a simple API for decrypting/encrypting single-user armor-encoded GPG files.

See the tests and documentation for more info.

Development

To run the tests, you need to generate a key for Testy McTestFace:

$ cd testing
$ gpg --gen-key
$ # Use ID "Testy McTestFace" and password "1234"
$ cd testing
$ gpg --yes --armor --recipient "Testy McTestFace" --trust-model always --encrypt hello.txt

Then you can run

$ go test -v

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GPGStore

type GPGStore struct {
	// contains filtered or unexported fields
}

GPGStore is the basic store object.

func New

func New(debug bool, keyring ...string) (*GPGStore, error)

New returns a new GPGStore. You can specify the verbosity (which uses logrus) and you can optionally specify a keyring folder to use to find secring.gpg and pubring.gpg. If the keyring folder is not supplied, or not found, it will search in the common places to find the correct folder and use that.

func (*GPGStore) BulkDecrypt

func (gs *GPGStore) BulkDecrypt(filenames []string, progress ...bool) (filecontents map[string]string, err error)

BulkDecrypt takes a list of filenames and then decrypts them in parallel and then returns a map with filename keys and the decrypted file contents as values. Files which have errors are quietly skipped.

func (*GPGStore) Debug

func (gs *GPGStore) Debug(on bool)

func (*GPGStore) Decrypt

func (gs *GPGStore) Decrypt(encrypted []byte) (decrypted []byte, err error)

Decrypt uses the supplied GPG parameters to decrypt armor-encoded GPG data.

func (*GPGStore) Encrypt

func (gs *GPGStore) Encrypt(unencrypted []byte) (encrypted []byte, err error)

Encrypt takes a string and returns a string that is armor encoded using the supplied GPG credentials.

func (*GPGStore) Identity

func (gs *GPGStore) Identity() string

func (*GPGStore) Init

func (gs *GPGStore) Init(identity string, passphrase string) error

Init uses the supplied identity and passphrase to determine the GPG parameters. The identity must be in the secret and public keychain, and returns an error otherwise. The passphrase is validated and returns an error if doesn't exist.

func (*GPGStore) ListPrivateKeys

func (gs *GPGStore) ListPrivateKeys() ([]string, error)

ListPrivateKeys returns a list of the names of keys available in the private key chain

func (*GPGStore) ListPublicKeys

func (gs *GPGStore) ListPublicKeys() ([]string, error)

ListPublicKeys returns a list of the names of keys available in the public key chain

type IncorrectPassphrase

type IncorrectPassphrase struct {
	// contains filtered or unexported fields
}

IncorrectPassphrase is thrown when the supplied passphrase doesn't match for the key

func (IncorrectPassphrase) Error

func (err IncorrectPassphrase) Error() string

type NoSuchKeyError

type NoSuchKeyError struct {
	// contains filtered or unexported fields
}

NoSuchKeyError is thrown when supplied GPG key name not available in private and public keychains

func (NoSuchKeyError) Error

func (err NoSuchKeyError) Error() string

type NoSuchKeyRingError

type NoSuchKeyRingError struct {
	// contains filtered or unexported fields
}

NoSuchKeyRing is thrown when supplied keyring containing the secret and public keys cannot be found

func (NoSuchKeyRingError) Error

func (err NoSuchKeyRingError) Error() string

Jump to

Keyboard shortcuts

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