encryption

package
v0.0.1-alpha83 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package encryption provides encryption utilities for secure credential storage.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidKey indicates the encryption key is invalid (must be 32 bytes for AES-256)
	ErrInvalidKey = errors.New("encryption key must be 32 bytes")
	// ErrInvalidCiphertext indicates the ciphertext is too short or corrupted
	ErrInvalidCiphertext = errors.New("ciphertext too short")
	// ErrDecryptionFailed indicates decryption failed (wrong key or corrupted data)
	ErrDecryptionFailed = errors.New("decryption failed")
)

Functions

This section is empty.

Types

type Encryptor

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

Encryptor provides AES-256-GCM encryption and decryption.

func NewEncryptor

func NewEncryptor(key []byte) (*Encryptor, error)

NewEncryptor creates a new Encryptor with the given 32-byte key.

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt decrypts ciphertext that was encrypted with Encrypt. Expects the nonce to be prepended to the ciphertext.

func (*Encryptor) DecryptJSON

func (e *Encryptor) DecryptJSON(ciphertext []byte, v any) error

DecryptJSON decrypts ciphertext and unmarshals the JSON result into v.

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(plaintext []byte) ([]byte, error)

Encrypt encrypts plaintext using AES-256-GCM. The nonce is prepended to the ciphertext.

func (*Encryptor) EncryptJSON

func (e *Encryptor) EncryptJSON(v any) ([]byte, error)

EncryptJSON encrypts a value as JSON using AES-256-GCM.

Jump to

Keyboard shortcuts

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