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 ¶
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 ¶
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.
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.