crypto

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package crypto provides AES-256-GCM encryption for secret values stored in the database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encryptor

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

Encryptor handles AES-256-GCM encryption and decryption.

func LoadOrGenerateKey

func LoadOrGenerateKey(keyPath string) (*Encryptor, error)

LoadOrGenerateKey loads an encryption key from a file, or generates a new one and writes it to that file if it doesn't exist. Returns a ready-to-use Encryptor.

func NewEncryptor

func NewEncryptor(keyBase64 string) (*Encryptor, error)

NewEncryptor creates an Encryptor from a base64-encoded 32-byte key.

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(encoded string) (string, error)

Decrypt decrypts a base64(nonce+ciphertext) string.

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(plaintext string) (string, error)

Encrypt encrypts plaintext and returns base64(nonce+ciphertext).

Jump to

Keyboard shortcuts

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