mock

package
v1.4.1-rc3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotImplemented is returned when a required Encryptor function is not set.
	ErrNotImplemented = errors.New("not implemented")
	// ErrInvalidXORKey is returned when the key for XOR encryption is not valid.
	ErrInvalidXORKey = errors.New("invalid xor key")
)

Functions

func NewChunkEncrypter added in v0.3.0

func NewChunkEncrypter(key []byte) encryption.ChunkEncrypter

Types

type Encryptor

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

Encryptor implements encryption Interface in order to mock it in tests.

func New

func New(opts ...Option) *Encryptor

New returns a new Encryptor configured with provided options.

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(data []byte) ([]byte, error)

Decrypt calls the configured decrypt function, or returns ErrNotImplemented if it is not set.

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(data []byte) ([]byte, error)

Encrypt calls the configured encrypt function, or returns ErrNotImplemented if it is not set.

func (*Encryptor) Key added in v0.3.0

func (e *Encryptor) Key() encryption.Key

Key has only bogus

func (*Encryptor) Reset

func (e *Encryptor) Reset()

Reset calls the configured reset function, if it is set.

type Option

type Option func(*Encryptor)

Option represents configures the Encryptor instance.

func WithDecryptFunc

func WithDecryptFunc(f func([]byte) ([]byte, error)) Option

WithDecryptFunc sets the Encryptor Decrypt function.

func WithEncryptFunc

func WithEncryptFunc(f func([]byte) ([]byte, error)) Option

WithEncryptFunc sets the Encryptor Encrypt function.

func WithKeyFunc added in v0.3.0

func WithKeyFunc(f func() encryption.Key) Option

WithKeyFunc sets the Encryptor Key function.

func WithResetFunc

func WithResetFunc(f func()) Option

WithResetFunc sets the Encryptor Reset function.

func WithXOREncryption

func WithXOREncryption(key []byte) Option

WithXOREncryption sets Encryptor Encrypt and Decrypt functions with XOR encryption function that uses the provided key for encryption.

Jump to

Keyboard shortcuts

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