cipher

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 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 AESConfiguration) *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 AESConfiguration

type AESConfiguration interface {
	config.Provider
}

type ChaCha20Configuration

type ChaCha20Configuration interface {
	config.Provider
}

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 {
	// contains filtered or unexported fields
}

func NewNoop

func NewNoop(c NoopConfiguration) *Noop

func (*Noop) Decrypt

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

Decrypt decode the hex message

func (*Noop) Encrypt

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

Encrypt encode message to hex

type NoopConfiguration

type NoopConfiguration interface {
	config.Provider
}

type Provider

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

type XChaCha20Poly1305

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

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