crypto

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package crypto provides authenticated symmetric encryption for data at rest — e.g. connector credentials sealed before they are written to Postgres. The core interfaces.Encryptor contract is backed here by AES-256-GCM with a fresh random nonce per message; the key is injected from configuration, never hardcoded.

Index

Constants

View Source
const KeySize = 32

KeySize is the required key length in bytes for AES-256.

Variables

This section is empty.

Functions

func New

func New(key []byte) (interfaces.Encryptor, error)

New builds an AES-256-GCM interfaces.Encryptor over a 32-byte key. It fails loudly on a key of the wrong length rather than silently truncating or padding it.

func NewFromConfig

func NewFromConfig(cfg Config) (interfaces.Encryptor, error)

NewFromConfig builds an interfaces.Encryptor from cfg: it base64-decodes the key and fails loudly on a missing key, invalid base64, or a decoded length other than 32 bytes (New enforces the length), so bad key material is rejected at startup, not first use.

Types

type Config

type Config struct {
	// Key is the base64-encoded AES-256 key (32 bytes once decoded).
	Key string
}

Config carries the encryption key for NewFromConfig. The key is base64-encoded (32 bytes decoded) and sourced from secrets configuration — never a hardcoded literal.

Jump to

Keyboard shortcuts

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