security

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDecrypt = errors.New("decryption failed")

Functions

func GenerateNewKeyFile

func GenerateNewKeyFile(path string) error

Types

type Cipher

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

Cipher handles authenticated encryption using XChaCha20-Poly1305.

func NewCipher

func NewCipher(secret string) (*Cipher, error)

NewCipher creates a cipher. It attempts to decode secret as Base64. If decoding fails or length != 32, it hashes the string to generate a 32-byte key.

func (*Cipher) Decrypt

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

func (*Cipher) Encrypt

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

type Manager

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

func LoadKeys

func LoadKeys(path string) (*Manager, error)

func (*Manager) Mint

func (m *Manager) Mint(serviceName string, ttl time.Duration) (string, error)

func (*Manager) Verify

func (m *Manager) Verify(tokenString string) (string, error)

type TokenClaims

type TokenClaims struct {
	Service string `json:"svc"`
	jwt.RegisteredClaims
}

Jump to

Keyboard shortcuts

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