secrets

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package secrets is an interface for encrypting and decrypting secrets

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Init(...Option) error
	Options() Options
	String() string
	Decrypt([]byte, ...DecryptOption) ([]byte, error)
	Encrypt([]byte, ...EncryptOption) ([]byte, error)
}

Codec encrypts or decrypts arbitrary data. The data should be as small as possible

type DecryptOption

type DecryptOption func(*DecryptOptions)

DecryptOption sets DecryptOptions

func SenderPublicKey

func SenderPublicKey(key []byte) DecryptOption

SenderPublicKey is the Public Key of the Codec that encrypted this message

type DecryptOptions

type DecryptOptions struct {
	SenderPublicKey []byte
}

DecryptOptions can be passed to Codec.Decrypt

type EncryptOption

type EncryptOption func(*EncryptOptions)

EncryptOption Sets EncryptOptions

func RecipientPublicKey

func RecipientPublicKey(key []byte) EncryptOption

RecipientPublicKey is the Public Key of the Codec that will decrypt this message

type EncryptOptions

type EncryptOptions struct {
	RecipientPublicKey []byte
}

EncryptOptions can be passed to Codec.Encrypt

type Option

type Option func(*Options)

Option sets options

func PrivateKey

func PrivateKey(key []byte) Option

PrivateKey sets the asymmetric Private Key of this codec

func PublicKey

func PublicKey(key []byte) Option

PublicKey sets the asymmetric Public Key of this codec

func SecretKey

func SecretKey(key []byte) Option

SecretKey sets the symmetric secret key

type Options

type Options struct {
	SecretKey  []byte
	PrivateKey []byte
	PublicKey  []byte
	Context    context.Context
}

Options is a codec's options SecretKey or both PublicKey and PrivateKey should be set depending on the underlying implementation

Directories

Path Synopsis
Package box is an asymmetric implementation of config/secrets using nacl/box
Package box is an asymmetric implementation of config/secrets using nacl/box
Package secretbox is a config/secrets implementation that uses nacl/secretbox to do symmetric encryption / verification
Package secretbox is a config/secrets implementation that uses nacl/secretbox to do symmetric encryption / verification

Jump to

Keyboard shortcuts

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