cipher

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AES

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

func NewCryptAES

func NewCryptAES(c SecretsProvider) *AES

func (*AES) Decrypt

func (a *AES) Decrypt(ctx context.Context, ciphertext string) ([]byte, error)

Decrypt returns the decrypted aes data

func (*AES) Encrypt

func (a *AES) Encrypt(ctx context.Context, message []byte) (string, error)

Encrypt return a AES encrypt of plaintext

type Cipher

type Cipher interface {
	// Encrypt encrypts the (binary) message and returns a hex-encoded binary ciphertext
	// or an error if the encryption failed.
	//
	// If the message is empty, the ciphertext is also empty and no error is returned.
	Encrypt(ctx context.Context, message []byte) (string, error)

	// Decrypt takes a hex-encoded binary ciphertext and decrypts it or returns an error if the decryption
	// failed.
	//
	// If the ciphertext is empty a nil byte slice is returned.
	Decrypt(ctx context.Context, encrypted string) ([]byte, error)
}

Cipher provides methods for encrypt and decrypt string

type Noop

type Noop struct{}

Noop is default cipher implementation witch does not do encryption

func NewNoop

func NewNoop() *Noop

func (*Noop) Decrypt

func (*Noop) Decrypt(_ context.Context, ciphertext string) ([]byte, error)

Decrypt decode the hex message

func (*Noop) Encrypt

func (*Noop) Encrypt(_ context.Context, message []byte) (string, error)

Encrypt encode message to hex

type Provider

type Provider interface {
	Cipher(ctx context.Context) Cipher
}

type SecretsProvider added in v1.3.0

type SecretsProvider interface {
	SecretsCipher(ctx context.Context) [][32]byte
}

type XChaCha20Poly1305

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

func NewCryptChaCha20

func NewCryptChaCha20(c SecretsProvider) *XChaCha20Poly1305

func (*XChaCha20Poly1305) Decrypt

func (c *XChaCha20Poly1305) Decrypt(ctx context.Context, ciphertext string) ([]byte, error)

Decrypt decrypts data using 256 bit key

func (*XChaCha20Poly1305) Encrypt

func (c *XChaCha20Poly1305) Encrypt(ctx context.Context, message []byte) (string, error)

Encrypt returns a ChaCha encryption of plaintext

Jump to

Keyboard shortcuts

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