crypto

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissmatchedAESNonceSize = errors.New("missmatched nonce size")
View Source
var ErrMissmatchedChaCha20NonceSize = errors.New("missmatched nonce size")

Functions

This section is empty.

Types

type AES

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

func NewAES

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

NewAES creates a new AES encrypter with the provided key. Key should be 16, 24, or 32 bytes for AES-128, AES-192, or AES-256.

func (*AES) Decrypt

func (e *AES) Decrypt(value []byte) ([]byte, error)

Decrypt decrypts the ciphertext using AES-GCM. Expects nonce to be prepended to ciphertext.

func (*AES) Encrypt

func (e *AES) Encrypt(value []byte) ([]byte, error)

Encrypt encrypts the plaintext using AES-GCM. Returns ciphertext with nonce prepended.

type ChaCha20

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

func NewChaCha20

func NewChaCha20(key []byte) (*ChaCha20, error)

NewChaCha20 creates a new ChaCha20-Poly1305 encrypter. Key must be exactly 32 bytes.

func (*ChaCha20) Decrypt

func (e *ChaCha20) Decrypt(value []byte) ([]byte, error)

Decrypt decrypts the ciphertext using ChaCha20-Poly1305. Expects nonce to be prepended to ciphertext.

func (*ChaCha20) Encrypt

func (e *ChaCha20) Encrypt(value []byte) ([]byte, error)

Encrypt encrypts the plaintext using ChaCha20-Poly1305. Returns ciphertext with nonce prepended.

Jump to

Keyboard shortcuts

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