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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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