crypto

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package crypto provides authenticated symmetric encryption (AES-256-GCM) for secrets stored at rest, such as registry credentials. The key is generated once and persisted alongside the other server secrets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

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

Cipher seals and opens short secrets with AES-GCM. The nonce is random per message and prepended to the ciphertext; output is base64 for DB storage.

func New

func New(key []byte) (*Cipher, error)

New returns a Cipher for a 16/24/32-byte key (32 = AES-256).

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(enc string) (string, error)

Decrypt reverses Encrypt. A wrong key or tampered ciphertext yields an error.

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(plain string) (string, error)

Encrypt seals plaintext and returns base64(nonce || ciphertext).

Jump to

Keyboard shortcuts

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