secrets

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package secrets encrypts sensitive values (app/db env blobs) at rest with AES-GCM. The master key lives in <dataDir>/keys/master.key (0600), created on first boot; STACKR_MASTER_KEY (64 hex chars) overrides it so the key can live apart from the database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(s string) (string, error)

Decrypt reverses Encrypt. Values without the prefix (legacy plaintext) pass through unchanged.

func Encrypt

func Encrypt(s string) string

Encrypt returns "enc:<base64(nonce||ciphertext)>". Empty and already encrypted input pass through unchanged.

func Generate

func Generate(length int, numbers, symbols bool) string

Generate mints a random string of exactly length characters from letters plus the opted-in classes, the generator behind `default: generated` config secrets. Same panic rule as RandomHex.

func Key

func Key() string

Key returns the master key in the same hex form the key file holds, so a backup can write it back out verbatim. Empty before Load.

func Load

func Load(path string) error

Load initializes the cipher from STACKR_MASTER_KEY or the key file at path, generating the file if absent.

func RandomHex

func RandomHex(n int) string

RandomHex is n cryptographically random bytes, hex-encoded, the generator behind every credential stackr mints for itself: db passwords, registry passwords, webhook tokens, invite tokens.

It panics rather than returning an error. A machine that cannot produce randomness must not go on to hand out a guessable password, and every caller would otherwise write the same "if err != nil { panic }" it replaces.

Types

This section is empty.

Jump to

Keyboard shortcuts

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