crypto

package
v0.2.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encryptor

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

Encryptor wraps AES-256-GCM authenticated encryption. The key is derived from an arbitrary-length secret via SHA-256.

func New

func New(secret string) *Encryptor

New derives a 32-byte AES key from secret and returns an Encryptor.

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(ciphertext string) (string, error)

Decrypt decodes and decrypts the base64 blob produced by Encrypt.

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(plaintext string) (string, error)

Encrypt encrypts plaintext and returns a URL-safe base64 string. Layout: [12-byte nonce][ciphertext+16-byte GCM tag].

Jump to

Keyboard shortcuts

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