Help us shape the future of Go! Take the 2026 Go Developer Survey

crypto

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package crypto provides an AES-GCM helper for encrypting small at-rest payloads such as RSA private keys. Callers bring their own 32-byte master key (typically loaded from a secret store).

Index

Constants

View Source
const KeySize = 32

KeySize is the required master key length in bytes (AES-256).

Variables

View Source
var (
	ErrKeySize    = errors.New("crypto: master key must be 32 bytes")
	ErrCiphertext = errors.New("crypto: ciphertext too short")
)

Sentinel errors returned by Encrypt and Decrypt.

Functions

func Decrypt

func Decrypt(key, ct []byte) ([]byte, error)

Decrypt reverses Encrypt.

func Encrypt

func Encrypt(key, plaintext []byte) ([]byte, error)

Encrypt seals plaintext with key, returning nonce||ciphertext||tag. Callers store the returned slice as-is.

Types

This section is empty.

Jump to

Keyboard shortcuts

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