symmetric

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package symmetric provides authenticated symmetric encryption using AES-GCM.

Use this package when you need to encrypt and decrypt data with a shared secret key. The package handles nonce generation automatically, ensuring each encryption operation produces unique ciphertext even for identical plaintext inputs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

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

Cipher provides AES-GCM encryption and decryption.

func New

func New(key string, opts ...Option) (*Cipher, error)

New allocates and configures a Cipher.

func (*Cipher) Decrypt

func (cipher *Cipher) Decrypt(encryptedData []byte) ([]byte, error)

Decrypt performs Cipher-GCM decryption on a nonce-prefixed ciphertext. It returns the recovered plaintext and an error if any occurs during the decryption process.

func (*Cipher) Encrypt

func (cipher *Cipher) Encrypt(data []byte) ([]byte, error)

Encrypt takes a slice of data and returns an encrypted version using Cipher-GCM with a unique nonce. It returns the nonce-prefixed ciphertext and an error if any occurs during the encryption process.

type Option

type Option func(*config)

Option is optional configuration of the encryptor.

func WithBlockCipherProvider

func WithBlockCipherProvider(provider func(key []byte) (cipher.Block, error)) Option

WithBlockCipherProvider overwrites the provider for the block cipher.

func WithRandReader

func WithRandReader(reader io.Reader) Option

WithRandReader overwrites the random data function.

Jump to

Keyboard shortcuts

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