crypto

package
v0.0.0-...-0fefa07 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data Data) ([]byte, error)

Decode is an opiniated Base64 decoder function using a strict variant of base64.RawStdEncoding for data processing

Types

type Data

type Data []byte

Data is a functional wrapper around a byte slice providing various feature not found in the standard library

func Encode

func Encode(data []byte) (Data, error)

Encode is an opiniated Base64 encoder function using a strict variant of base64.RawStdEncoding for data processing

func NewData

func NewData(b *bytes.Buffer) Data

NewData creates a Data instance from the bytes.Buffer.Bytes()

func ParseData

func ParseData(r io.Reader) (Data, error)

ParseData drains the provided reader instance and creates a Data instance from the output

func (Data) Copy

func (d Data) Copy() Data

func (Data) String

func (d Data) String() string

type Encrypter

type Encrypter interface {
	Encrypt(data Data) (Data, error)
	Decrypt(data Data) (Data, error)
}

Encrypter is a processing contract for data in- and output. It is up to the implementation to decide if they can consume their own output multiple times.

type EncrypterPlugin

type EncrypterPlugin interface {
	// Encrypter is an identification method. The return value is
	// expected to be stable over multiple invocations.
	Encrypter() string
	// NewEncrypter is a factory method. The input parameter
	// is a directory for potential data persistence, which might not exist.
	NewEncrypter(string) (Encrypter, error)
}

EncrypterPlugin is a factory contract for encryption systems.

type Encrypters

type Encrypters map[string]Encrypter

Encrypters is a map implementation with convenience functions

func (Encrypters) Add

func (e Encrypters) Add(provider string, impl Encrypter) bool

Add stores the given encrypter implementation under the given key. Keys can only be used once and return false on collisions. The storage key is sanitized for unambiguous access later on.

func (Encrypters) Get

func (e Encrypters) Get(provider string) (Encrypter, bool)

Get retrieves a previously stored encrypter implementation using the given key as lookup. If no instance is available, false is returned.

func (Encrypters) Providers

func (e Encrypters) Providers() []string

Providers returns all the keys of the map.

type SecretsGenerator

type SecretsGenerator interface {
	// GenerateSecrets is used to create any configuration, secrets, or otherwise
	// persistent data for later de-/encryption. If the first parameter is true,
	// any existing data is expected to be overwritten. The given context contains
	// additional utilities.
	GenerateSecrets(bool, context.Context) error
}

SecretsGenerator is implemented by encryption plugins which utilize some kind of persistent information during processing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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