secrets

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidKeyLength indicates the provided key is not the required size.
	ErrInvalidKeyLength = errors.New("secrets: encryption key must be 32 bytes")
	// ErrCiphertextTooShort indicates the ciphertext payload is shorter than the nonce.
	ErrCiphertextTooShort = errors.New("secrets: ciphertext too short")
)

Functions

This section is empty.

Types

type Cipher

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

Cipher wraps AES-GCM helpers for encrypting sensitive blobs before storage.

func NewCipher

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

NewCipher constructs a Cipher from the provided key bytes.

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(encoded string) ([]byte, error)

Decrypt reverses Encrypt and returns the original plaintext bytes.

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(plaintext []byte) (string, error)

Encrypt serialises plaintext using AES-256-GCM and returns a base64 payload.

Jump to

Keyboard shortcuts

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