crypto

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package crypto provides AES-256-GCM encryption/decryption utilities

Index

Constants

View Source
const (
	// EncryptedPrefix is prepended to encrypted values to identify them.
	EncryptedPrefix = "enc:"
)

Variables

View Source
var (
	ErrInvalidKey        = errors.New("encryption key must be 32 bytes")
	ErrInvalidCiphertext = errors.New("invalid ciphertext format")
	ErrDecryptionFailed  = errors.New("decryption failed")
)

Functions

func Decrypt

func Decrypt(ciphertext, key string) (string, error)

Decrypt decrypts ciphertext using AES-256-GCM with the provided key. Expects base64 encoded ciphertext with "enc:" prefix.

func Encrypt

func Encrypt(plaintext, key string) (string, error)

Encrypt encrypts plaintext using AES-256-GCM with the provided key. Returns base64 encoded ciphertext with "enc:" prefix.

func IsEncrypted

func IsEncrypted(value string) bool

IsEncrypted checks if a value is encrypted by looking for the prefix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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