pgp

package
v0.0.0-...-453cd44 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 10 Imported by: 10

Documentation

Overview

Package pgp contains the code related to both code and host signing and encryption.

Index

Constants

View Source
const DefaultKeyringFile = "keyring.pgp"

DefaultKeyringFile is the default file name for keyrings.

Variables

CONFIG set default Hash.

Functions

func ParseIdentity

func ParseIdentity(identity string) (name, comment, email string, err error)

ParseIdentity parses an identity into name, comment and email components.

Types

type PGP

type PGP struct {
	Entity *openpgp.Entity
}

PGP contains base entity.

func Generate

func Generate(name, comment, email string, hash *crypto.Hash) (*PGP, error)

Generate creates new key pair. This key pair must be saved or it will be lost.

func Import

func Import(privKeyPath string) (*PGP, error)

Import private key from defined path.

func (*PGP) Decrypt

func (obj *PGP) Decrypt(encString string) (string, error)

Decrypt an encrypted msg.

func (*PGP) Encrypt

func (obj *PGP) Encrypt(to *openpgp.Entity, msg string) (string, error)

Encrypt message for specified entity.

func (*PGP) EncryptMsg

func (obj *PGP) EncryptMsg(to *openpgp.Entity, msg string) (*bytes.Buffer, error)

EncryptMsg encrypts the message.

func (*PGP) GetIdentities

func (obj *PGP) GetIdentities() (string, error)

GetIdentities return the first identities from current object.

func (*PGP) SaveKey

func (obj *PGP) SaveKey(path string) error

SaveKey writes the whole entity (including private key!) to a .gpg file.

func (*PGP) WriteFile

func (obj *PGP) WriteFile(path string, buff *bytes.Buffer) error

WriteFile from given buffer in specified path.

Jump to

Keyboard shortcuts

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