encrypt

package
v0.0.0-...-4409437 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 6 Imported by: 3

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
}

AES provides encryption and decryption using the AES-GCM mode.

func NewAES

func NewAES(key []byte) (*AES, error)

NewAES creates a new AES instance with the provided key. The key must be one of the following lengths: 16, 24, or 32 bytes, corresponding to AES-128, AES-192, and AES-256, respectively.

func (*AES) Decrypt

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

Decrypt decrypts the given ciphertext using AES-GCM. The context parameter is ignored but is included for interface compliance. The ciphertext must include the nonce as its prefix.

func (*AES) Encrypt

func (a *AES) Encrypt(_ context.Context, plaintext []byte) ([]byte, error)

Encrypt encrypts the given plaintext using AES-GCM. The context parameter is ignored but is included for interface compliance. The resulting ciphertext includes the nonce prepended to the encrypted data.

type Encrypter

type Encrypter interface {
	// Encrypt returns the encrypted ciphertext.
	Encrypt(ctx context.Context, plaintext []byte) ([]byte, error)
	// Decrypt returns the decrypted plaintext.
	Decrypt(ctx context.Context, ciphertext []byte) ([]byte, error)
}

Encrypter defines an interface for encryption and decryption mechanisms. Implementations of this interface must support securely encrypting plaintext and decrypting ciphertext, optionally considering context for cancellation or deadlines.

Jump to

Keyboard shortcuts

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